PHP邮件程序无法使用客户端gmail id
我是php新手,当我设置PHP邮件程序无法使用客户端gmail id,php,phpmailer,Php,Phpmailer,我是php新手,当我设置 $Host = 'ssl://smtp.googlemail.com'; $Username = 'my gamil id'; $Password = 'my gmail password'; $Port = 465; Php邮件程序工作正常,但当我将其更改为 $Host = 'ssl://smtp.googlemail.com'; $Username = 'client gamil id'; $Password = 'client gmail password';
$Host = 'ssl://smtp.googlemail.com';
$Username = 'my gamil id';
$Password = 'my gmail password';
$Port = 465;
Php邮件程序工作正常,但当我将其更改为
$Host = 'ssl://smtp.googlemail.com';
$Username = 'client gamil id';
$Password = 'client gmail password';
$Port = 465;
邮件程序不工作,其显示错误消息
需要身份验证
我来自印度,客户来自美国,所以配置文件中是否有任何更改?
请帮帮我
这是我的mailer.php文件
include 'phpmailer/class.config.php';
include 'phpmailer/class.phpmailer.php';
include 'phpmailer/class.smtp.php';
session_start();
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->IsHTML();
$mail->SMTPAuth = true;
if (MailConfig::$Debug) {
$mail->Host = MailConfig::$DebugHost;
$mail->Username = MailConfig::$DebugUsername;
$mail->Password = MailConfig::$DebugPassword;
} else {
$mail->Host = MailConfig::$Host;
$mail->Username = MailConfig::$Username;
$mail->Password = MailConfig::$Password;
}
$Subject = "Payment Received";
//////
/////////////
if (MailConfig::$Debug)
$receipientEmail = "client@example.com";
else
$receipientEmail = "client@example.com";
$Body = "A payment of $ " . $_POST['payment'] . " has been credited in your account";
$mail->AddAddress($receipientEmail);
$mail->Subject = $Subject;
$mail->Body = $Body;
谢谢你的主机不正确。应该是:
$host = 'mail.gmail.com';
代码是:
$mail = new PHPMailer();
$mail->IsHTML();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the server
$mail->Host = MailConfig::$Host; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = MailConfig::$Username; // GMAIL username
$mail->Password = MailConfig::$Password;
注意
SMTPSecure
行能否显示您的PHP邮件代码?请检查我的PHP邮件代码如果您发现答案有用,请单击“勾选”符号接受答案。谢谢