1

我正在使用 PHP 邮件功能发送邮件,它被传递到所有其他邮件服务器,但不是 gmail。

这是我的标题

$headers = "From: Somename<sales@domain.net>\r\n";  
$headers .= "Reply-To: sales@domain.net\r\n".
$headers .="Return-Path: sales@domain.net\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .='X-Mailer: PHP/' . phpversion();

任何帮助将不胜感激。谢谢你。

4

2 回答 2

1

据我所知,你没有得到其余的代码,所以我可以看到有什么问题,所以我会向你发布我使用 gmail 发送电子邮件的代码

代码 :

    $sendmail = require_once('../lib/phpmailer/class.phpmailer.php');
include("../lib/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body = " Body Msg ";

$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "smtp.gmail.com"; // sets the SMTP server
$mail->Port       = 465;                    // set the SMTP port for the GMAIL server
$mail->Username   = "mail@gmail.com"; // SMTP account username
$mail->Password   = "pass";        // SMTP account password

$mail->SetFrom('$qemail', 'first name');

$mail->Subject    = "hi name";

$mail->MsgHTML($body);

$address = "mail@gmail.com";
$mail->AddAddress($address, "first name");

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
}

如果您愿意尝试代码,请不要忘记在 include 函数和 require_once 中为类设置正确的位置

于 2013-07-03T16:57:40.197 回答
1

我看你有

$headers .= "Reply-To: sales@domain.net\r\n".

在您的标题中,而不是

$headers .= "Reply-To: sales@domain.net\r\n";

你打错了“。” 而不是';',这就是它导致错误的原因。

于 2014-07-13T07:30:44.030 回答