使用PHPMailer發送單個電子郵件給收件人我沒有收到任何內容收件人:字段時,我將$mail->SingleTo = TRUE;
添加到我的代碼。個人電子郵件的PHPMailer設置發送空To:字段
當我刪除$mail->SingleTo = TRUE;
我收到的電子郵件地址爲收件人:是正確的。
這就是我得到:
reply-to xxxxxx <[email protected]>, No Reply <[email protected]>
to
date Mon, Mar 21, 2011 at 5:07 PM
subject Testing
mailed-by gmail.com
signed-by gmail.com
(其中XXXXXXX代表我的電子郵件地址。)
這裏是我的代碼:
if(isset($_POST['submit']))
{
require_once('PHPMailer_v5.1/class.phpmailer.php');
$mail = new PHPMailer();
$subject = $_POST['subject'];
$body = $_POST['emailbody'];
$to = $_POST['to'];
$mail->IsSMTP(); // telling the class to use SMTP
//$mail->Host = "localhost"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$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 = 587; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "*********"; // GMAIL password
$mail->SetFrom('[email protected]', 'XXXXXX');
$mail->AddReplyTo("[email protected]","No Reply");
$mail->Subject = $subject;
// After adding this line I'm getting an empty To: field
$mail->SingleTo = TRUE;
$mail->AddAddress("[email protected]", 'xyz abc');
$mail->AddAddress("[email protected]", 'abc xyz');
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
if(!$mail->Send()) {
$message= "Mailer Error: " . $mail->ErrorInfo;
}
else
{
$message= "Message sent!";
}
}
問題被接受,但賞金是開放的?我們可以得到一個爲什麼我們可以回答賞金? – 2011-04-25 19:31:51