I want to send conformation mail to registered user. I am using php mailer and smtp lib class file to send mail to registered user.
if(isset($_POST['submit']))
{
require "dbc.php";
$username = $_POST['username'];
$email = ($_POST['email'];
$password = $_POST['password'];
$enc_password = md5($password);
if($username && $email && $password)
{
$confirmcode = rand();
$query = mysql_query("INSERT INTO `tutorial` VALUES('','$username','$enc_password','$email','0','$confirmcode')");
$message =
"
Confirm Your Email
Click the link below to verify your account
http://www.example.com/emailconfirm.php?username=$username&code=$confirmcode
";
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/class.phpmailer.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/class.smtp.php');
$mail = new PHPMailer(true);
$from = "[email protected]";
$mail->IsSMTP();
//$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug = 1;
$mail->Host = 'smtp.us-east-1.amazonaws.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = '******';
$mail->Sender = $from;
$mail->From = $from;
$mail->AddReplyTo($email);
$mail->FromName ="Mail";
$mail->AddAddress($email);
$mail->Port = 25;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->WordWrap = 50;
$mail->Send();
echo "Registration Complete! Please confirm your email address";
}
}
But I got this error.
SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: No such host is known. (0) Fatal error: Uncaught exception 'phpmailerException' with message 'SMTP Error: Could not connect to SMTP host.' in C:\wamp\www\Email Confirmation\lib\class.phpmailer.php:1093 Stack trace: #0 C:\wamp\www\Email Confirmation\lib\class.phpmailer.php(971): PHPMailer->SmtpConnect() #1 C:\wamp\www\Email Confirmation\lib\class.phpmailer.php(845): PHPMailer->SmtpSend('Date: Mon, 14 M...', '???Confirm Your...') #2 C:\wamp\www\Email Confirmation\lib\class.phpmailer.php(763): PHPMailer->PostSend() #3 C:\wamp\www\Email Confirmation\register.php(61): PHPMailer->Send() #4 {main} thrown in C:\wamp\www\Email Confirmation\lib\class.phpmailer.php on line 1093