2013-08-07 97 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」; –