我一直试图找到解决此问题的方法。脚本的创建者不是很有帮助。他们告诉我让接收者检查垃圾邮件文件夹。我正在将它发送给我自己的几个测试邮件地址,并且检查了垃圾邮件/垃圾邮件。
我需要将电子邮件确认发送给客户。问题是:电子邮件只发送给GMail和AOL。雅虎,hotmail等没有收到电子邮件。电子邮件没有发送垃圾邮件。
与主机联系后,他们说我的共享IP可能已列入黑名单,我应该使用外部邮件服务器或SMTP。
我对PHP知之甚少,但我正在学习。我非常感谢你的帮助。
// ----测试脚本以查看服务器是否可以与GMail一起使用:
require_once "Mail.php";
$from = '<mymail.gmail.com>';
$to = '<somemail.yahoo.com>';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'mygmail@gmail.com',
'password' => 'myPASS'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
// ----错误:身份验证失败[SMTP:从服务器收到无效的响应代码(代码:534,响应:5.7.14请通过Web浏览器登录,然后重试。 // ----也试过$ host =&#39; smtp.gmail.com&#39 ;;和不同的端口
// ----脚本中的函数php文件中的脚本
function sendMail($email, $subject, $template,$serviceID, $data=null) {
global $baseDir;
$serviceSettings = getService($serviceID);
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "From: 'MyName' <mymail@mydomain.net> \n";
if ($data == null) {
$message = $template;
} else {
$data ['{%server%}'] = $_SERVER['SERVER_NAME'];
foreach ($data as $k => $v) {
$$k = $v;
}
ob_start();
include MAIN_PATH . "/emailTemplates/{$template}";
$templ = ob_get_contents();
ob_clean(); //$templ=file_get_contents($_SERVER["DOCUMENT_ROOT"].$baseDir."emailTemplates/{$template}");
$message = strtr($templ, $data);
}
//$message.="<br><br><a href='http://{$_SERVER['SERVER_NAME']}'><img src='http://{$_SERVER['SERVER_NAME']}/images/logo_sm.png'></a>";
mail($email, $subject, $message, $headers);
}
function sendMailFile($email, $subject, $template,$serviceID, $data=null,$file=null) {
global $baseDir;
$boundary = "--" . md5(uniqid(time()));
$EOL = PHP_EOL;
$serviceSettings = getService($serviceID);
$headers = "MIME-Version: 1.0;$EOL";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"$EOL";
$headers .= "From: 'MyName' <mymail@mydomain.net> $EOL";
$multipart = "--$boundary$EOL";
$multipart .= "Content-Type: text/html; charset=utf-8$EOL";
$multipart .= "Content-Transfer-Encoding: Quot-Printed$EOL";
$multipart .= $EOL;
if ($data == null) {
$message = $template;
} else {
$data ['{%server%}'] = $_SERVER['SERVER_NAME'];
foreach ($data as $k => $v) {
$$k = $v;
}
ob_start();
include MAIN_PATH . "/emailTemplates/{$template}";
$templ = ob_get_contents();
ob_clean();
//$templ=file_get_contents($_SERVER["DOCUMENT_ROOT"].$baseDir."emailTemplates/{$template}");
$message = strtr($templ, $data);
}
$multipart .=$message;
$name = "addToCalendar.ics";
$multipart .= "$EOL--$boundary$EOL";
$multipart .= "Content-Type: application/octet-stream; name=\"$name\"$EOL";
$multipart .= "Content-Transfer-Encoding: base64$EOL";
$multipart .= "Content-Disposition: attachment; filename=\"$name\"$EOL";
$multipart .= $EOL; // Ãâ€-EDITED-Out-Encrypted-Code-On-Purpose-»Ã°
$multipart .= chunk_split(base64_encode($file));
$multipart .= "$EOL--$boundary--$EOL";
mail($email, $subject, $multipart, $headers);
}
有没有人认为我可以使用某种邮件系统来使用这个脚本来学习我对主机的限制?
谢谢!
答案 0 :(得分:0)
您能解释一下,错误534是一直发生的,还是只是在尝试@gmail以外的电子邮件地址时。等?
如果是这样的话,我会问你的服务器上是否有防火墙,是否阻止了传出端口465?
如果仅在发送到其他电子邮件地址时创建错误,那么smtp主机不会出现问题,但是当Google将电子邮件转发到全球其他邮件服务器时。