PHP邮件程序不使用客户端gmail id

时间:2013-10-18 10:18:51

标签: php phpmailer

我是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;

邮件程序无法正常工作,并显示错误消息

  

需要身份验证

我来自印度,美国的客户,配置文件是否有任何变化? 请帮帮我

这是我的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;

谢谢

1 个答案:

答案 0 :(得分: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