Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail function

Status
Not open for further replies.

DaSe

Programmer
Feb 14, 2008
149
GB
Hi PHP guys...
All I wanna do is the user to receive an activation link after an easy registration. I do everything locally and I set up a local mail server either. When a user enters their mail in a text input how can a link be redirected to this particular mail ? I've been trying mail() but with no results.Any comments max appreciated. Here's the script :

-----------------


$email = mysql_real_escape_string($_POST['email']);





//Get MD5 hash of password

$password = ($_POST['password']);



//Check to see if username exists

$sql = mysql_query("SELECT username FROM usersystem WHERE username = '$username'");


If (mysql_num_rows($sql)>0)

{

die ("This username has been already taken!.");

}





$any=mysql_query("INSERT INTO usersystem (username, password, email) VALUES ( '$username', '$password', '$email')") or die (mysql_error()); echo "<html><br/><br/>Account created.</html>";

if ($any) {
$to = "$email" ;
$from = "newuser@localhost";
$subject = "Complete yourdomain registration";
//Begin HTML Email Message
$message = "Hi $firstname, Thank you for submitting your mail!" ;


//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text\r\n";

mail($to, $subject, $message, $headers);
mail ($to) ;

}
}
 
mail() relies on there being an email (SMTP) server available than cant take the email and send it.

If the site is hosted on a unix based server is normally includes an SMTP server that mail can use.

If its on a Windows machine then you'd have to configure one, or point the mail configuration in the php.ini file to one that it can use.

I do everything locally and I set up a local mail server either
does this mean you have a local email server or not?

Does your ISP, and /or webhost maybe offer an SMTP server you can use?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi ,
I'm using XAMPP.And one of its options is "Mercury mail" that can set up the local mail and account.So I have "newuser@localhost" in my outlook set up properly and am able to receive any mail from postmaster@localhost. So in other words : when I register on my machine ( windows ) I can see the submissions in PHPmyAdmin in mySQL locally - but then I when submit let's say my own mail in registration file I don't get anything in my outlook on this mail.
 
Have you checked then the Mercury Mail logs see if its actually sending the emails?

As long as the mail() function returns true then it means its successfully handing the email to the server. So its up to it to send it.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ok. Thanks I'll try a few options.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top