我正在制作一个简单的 PHP 邮件发送器,一次将图像发送到多个地址。不知道为什么,但无论我使用哪个电子邮件管理器发送电子邮件,电子邮件都会不断到达垃圾邮件文件夹......
以下是我调用 PHP 邮件发送器文件的方法:
$.ajax({ url: 'mail_sender.php?receiver=' + receiver + '&=lang' + lang,
success: function (response)
{
console.log('Mails ' + response);
}
});
这是我的 PHP 文件结构:
<?php
// Reciever
$_to = $_GET["receiver"];
$_lang = $_GET["lang"];
// subject
$subject = 'My Subject';
// sender
$sender = "[email protected] /cdn-cgi/l/email-protection";
// message
$message = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<META name="generator" content="HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org">
<TITLE></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<img src='."https://www.mysite.es/demo/img/emails/imagen_".$_lang.".jpg".' />
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = "Reply-To: <[email protected] /cdn-cgi/l/email-protection> \r\n";
$headers .= "Return-Path: <[email protected] /cdn-cgi/l/email-protection>" . "\r\n";
$headers .= "From: <[email protected] /cdn-cgi/l/email-protection>" . "\r\n";
$headers .= "Organization: My organization" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
$headers .= "X-Priority: 3" . "\r\n";
$headers .= "X-Mailer: PHP/". phpversion();
// Mail it
$ret = mail($_to, $subject, $message, $headers);
if ( $ret == '' || $ret )
{
echo $ret;
}else{
echo $ret;
}
?>
有人可以提供一些线索吗?
非常感谢!
尝试发送纯文本电子邮件而不是 HTML(如果这适合您的需要)。根据我的经验,HTML 经常会触发垃圾邮件过滤器,但如果您确实需要使用 HTML,请尝试查看 mailchimp 使用的一些电子邮件模板。
https://github.com/mailchimp/Email-Blueprints https://github.com/mailchimp/Email-Blueprints
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)