2013-08-07 98 views
2

我有PHP MAILER函数的问题。我使用GMAIL SMTP身份验证发送电子邮件,并且其工作完美,但我想设置“发件人”电子邮件,如“[email protected]”,但它无法正常工作。PHP邮件程序 - SMTP GMAIL验证

我用下面的代码来设置“发件人”电子邮件

$mail    = new PHPMailer(); 

$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host  = "mail.gmail.com"; // SMTP server 
$mail->SMTPDebug = 0;      // enables SMTP debug information (for testing) 
$mail->SMTPAuth = true;     // enable SMTP authentication 
$mail->SMTPSecure = "ssl";     // sets the prefix to the servier 
$mail->Host  = "smtp.gmail.com";  // sets GMAIL as the SMTP server 
$mail->Port  = 465;     // set the SMTP port for the GMAIL server 
$mail->Username = "[email protected]"; // GMAIL username 
$mail->Password = "[email protected]"; 

$mail->SetFrom("[email protected]","Domian"); 

它显示我的默认电子邮件[email protected]而不是[email protected]

请帮助我。

在此先感谢!

回答

1

它将进入

$mail->From = "[email protected]"; 
$mail->FromName = "Mailer"; 
+0

如果我的答案帮助或不只是让我知道或标记为答案! –

+0

获取相同的问题。我已经使用此代码来设置自定义标题。 $ MAIL-> AddCustomHeader( '发件人:[email protected]'); –

+0

尝试$ mail-> From =“[email protected]”; $ mail-> FromName =“Mailer”; –