我是 php 新手,我在设置 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';
$Port = 465;
邮件程序不工作,并显示错误消息
需要身份验证
我来自印度,客户来自美国,所以配置文件有什么变化吗?请帮助我
这是我的邮件.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
行