phpmailer发送电子邮件后出错

时间:2014-09-01 11:22:35

标签: php ssl smtp gmail phpmailer

enter image description here

代码: -

$mail  = new PHPMailer();
$body="<b>This mail is sent using PHP Mailer</b>";#HTML tags can be included
$mail->IsSMTP();
$mail->SMTPAuth  = true;                 #enable SMTP authentication
$mail->SMTPSecure = "tls";               #sets the prefix to the server
$mail->Host  = "smtp.gmail.com";         #sets GMAIL as the SMTP server
$mail->Port       = 587;                 #set the SMTP port
$mail->Username   = "morelifelondon@gmail.com";     #your gmail username
$mail->Password   = "***********";                  #Your gmail password
$mail->From = $email;    
$mail->FromName   = $name ;                
$mail->Subject    = "Enquiry";
$mail->Body    = $messages;
$mail->AddAddress("morelifelondon@gmail.com","contact");
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Mail has Been Sent.';
}
}

我希望morelifelondon@gmail.com替换为abhishek@gmail.com。这可能吗 ?

1 个答案:

答案 0 :(得分:0)

$mail->AddAddress("abhishek@gmail.com","contact");

或使用

$mail->AddCC("abhishek@gmail.com","contact");