当我的web应用程序提交表单时,我使用下面的代码片断使用phpmailer类inorder发送使用gmail服务器的电子邮件!虽然它适用于我的个人Gmail地址,但当我用我的客户端Gmail地址和密码替换我的Gmail地址和密码时,它不会发送电子邮件!phpmailer发送来自任何gmail的电子邮件
我该如何纠正这个问题?
require "phpmailer/class.phpmailer.php"; //include phpmailer class
// Instantiate Class
$mail = new PHPMailer();
// Set up SMTP
$mail->IsSMTP(); // Sets up a SMTP connection
$mail->SMTPAuth = true; // Connection with the SMTP does require authorization
$mail->SMTPSecure = "ssl"; // Connect using a TLS connection
$mail->Host = "smtp.gmail.com"; //Gmail SMTP server address
$mail->Port = 465; //Gmail SMTP port
$mail->Encoding = '7bit';
// Authentication
$mail->Username = "[email protected]"; // Your full Gmail address
$mail->Password = "******"; // Your Gmail password
// Compose
$mail->SetFrom($_POST['emailid'], $_POST['fullname']);
$mail->AddReplyTo($_POST['emailid'], $_POST['fullname']);
$mail->Subject = "Pharmacy order confirmaton"; // Subject (which isn't required)
$mail->MsgHTML($message);
// Send To
$mail->AddAddress($_POST["Email"], "Recipient Name"); // Where to send it - Recipient
$result = $mail->Send(); // Send!
$message = $result ? 'Successfully Sent!' : 'Sending Failed!';
unset($mail);
当我送我的客户的电子邮件消息,我得到错误信息:
SMTP Error: Could not authenticate.
我怎样才能解决这个问题?