完成邮件标题 [英] Complete mail header

查看:121
本文介绍了完成邮件标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一组邮件头连接到PHP中的 mail()函数。我们在其中发送带有HTML的电子邮件,有时像 Yahoo Mail 这样的服务会阻止他们。因此,我需要确保我至少提供了正确的标题。

I need a set of mail headers to attach to my mail() function in PHP. I send emails with HTML in them, and sometimes services like Yahoo Mail block them. Therefore I need to make sure that I am at least providing the right headers.

// To send HTML mail, the 'Content-type' header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: MyCompany <welcome@mycompany.com>' . "\r\n";  

还有什么我应该添加的吗?

Is there anything else I should add?

推荐答案

    $headers  = "From: testsite < mail@testsite.com >\n";
    $headers .= "Cc: testsite < mail@testsite.com >\n"; 
    $headers .= "X-Sender: testsite < mail@testsite.com >\n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    $headers .= "X-Priority: 1\n"; // Urgent message!
    $headers .= "Return-Path: mail@testsite.com\n"; // Return path for errors
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n";

这篇关于完成邮件标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆