2

我是 php 新手,设置时我的 php 邮件程序有问题

$Host = 'ssl://smtp.googlemail.com';
$Username = 'my gamil id';
$Password = 'my gmail password';
$Port = 465;

Php mailer 工作正常,但是当我将其更改为

$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;

谢谢

4

1 回答 1

1

您的主机不正确。它应该是:

$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线

于 2013-10-18T11:13:18.597 回答