![](/img/trans.png)
[英]Email Attachments using php mail() function - Working for gmail but not working for yahoo
[英]Why isn't my gmail or yahoo email accounts receiving mail when I use this PHP mail function
具有标题的send_mail函数。 是什么原因阻止了它的接收。 我知道它至少有时会起作用,我的工作电子邮件收到的效果很好。
可能需要注意的另一件事:-使用不同的ssl页面,该功能确实已正确发送到gmail-在这个完全独立的域上,事实并非如此。
function send_mail($from,$fromName,$to,$object,$bodyText,$bodyHtml){
$site = "mywebsite.ca";
$from = $fromName." <".$from.">";
$limite = "_----------=_parties_".md5(uniqid (rand()));
$header = "Reply-to: ".$from."\n";
$header .= "From: ".$from."\n";
$header .= "X-Sender: <".$site.">\n";
$header .= "X-Mailer: PHP\n";
$header .= "X-auth-smtp-user: ".$from." \n";
$header .= "X-abuse-contact: ".$from." \n";
$header .= "Date: ".date("D, j M Y G:i:s O")."\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/alternative; boundary=\"".$limite."\"";
$message = "";
$message .= "--".$limite."\n";
$message .= "Content-Type: text/plain\n";
$message .= "charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $bodyText;
$message .= "\n\n--".$limite."\n";
$message .= "Content-Type: text/html; ";
$message .= "charset=\"iso-8859-1\"; ";
$message .= "Content-Transfer-Encoding: 8bit;\n\n";
$message .= $bodyHtml;
$message .= "\n--".$limite."--";
if(mail($to, $object, $message, $header)) return true;
else return false;
}
为什么要在同一变量中合并Text
和HTML
内容类型?
$message = "";
$message .= "--".$limite."\n";
$message .= "Content-Type: text/plain\n";
$message .= "charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $bodyText;
$message .= "\n\n--".$limite."\n";
$message .= "Content-Type: text/html; ";
$message .= "charset=\"iso-8859-1\"; ";
$message .= "Content-Transfer-Encoding: 8bit;\n\n";
$message .= $bodyHtml;
仅使用其中任何一个
喜欢而不是上面
$message .= "\n\n--".$limite."\n";
$message .= "Content-Type: text/html; ";
$message .= "charset=\"iso-8859-1\"; ";
$message .= "Content-Transfer-Encoding: 8bit;\n\n";
$message .= $bodyHtml;
if(mail($to, $object, $message, $header)) return true;
else return false;
这是将邮件发送到您的电子邮件的代码,请尝试对其进行调试,特别是$ to变量中的所有变量,因为它将邮件发送到您的电子邮件中。
尝试这个
if(mail($to,$object,$message,$header)){
//echo all
}
else{
//echo mssage not submit
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.