我正在制作一个简单的 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 = "sender@sender.es";
// 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: <sender@sender.es> \r\n";
$headers .= "Return-Path: <sender@sender.es>" . "\r\n";
$headers .= "From: <sender@sender.es>" . "\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;
}
?>
谁能提供一些线索?
非常感谢!