如何防止通过 PHP mail() 发送的邮件成为垃圾邮件?
我正在使用 PHP 的 mail() 函数发送电子邮件(sendmail 进程正在运行)。但所有邮件都会变成垃圾邮件(对于 gmail)。我已经尝试了很多在网上找到的技巧,但没有一个有效,请告诉我任何可靠的技巧。
I am using PHP's mail() function to send emails (sendmail process is running). But all the mails are going to spam (in case of gmail). I have tried many tricks that I found on the net but none is working, please tell me about any sure-shot trick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您必须添加针头:
示例代码:
You must to add a needle headers:
Sample code :
没有确定的投篮技巧。您需要探究您的邮件被归类为垃圾邮件的原因。 SpamAssassin 有一个页面描述为合法发件人避免误报的一些提示。另请参阅编码恐怖:所以你想发送一些电子邮件(通过代码)
There is no sure shot trick. You need to explore the reasons why your mails are classified as spam. SpamAssassin hase a page describing Some Tips for Legitimate Senders to Avoid False Positives. See also Coding Horror: So You'd Like to Send Some Email (Through Code)
尝试 PHP 邮件程序库。
或者通过 SMTP 发送邮件,在发送前对其进行过滤。
另外尝试提供所有详细信息,例如
FROM
、return-path
。Try PHP Mailer library.
Or Send mail through SMTP filter it before sending it.
Also Try to give all details like
FROM
,return-path
.这对我来说效果很好。它包括带有图像和链接的邮件,适用于各种邮件 ID。线索是完美地使用所有标题。
如果您从本地主机测试它,请在检查之前设置以下内容:
如何设置从本地主机 xampp 发送的邮件:
注释
D:/xampp/sendmail/sendmail.ini
中的所有内容并提及下面在[发送邮件]
smtp_server=smtp.gmail.com
smtp_端口=587
error_logfile=错误.log
debug_logfile=调试.log
[电子邮件受保护]
auth_password=您的邮件密码
[电子邮件受保护]
在
D:/xampp/php/php.ini
一个。下
[邮件功能]
SMTP = smtp.gmail.com
smtp_port = 587
587设置
sendmail_from = [电子邮件受保护]
c.取消注释 sendmail_path = "\"D:\xamp\sendmail\sendmail.exe\" -t"
因此它应该如下所示
。评论 sendmail_path="D:\xamp\mailtodisk\mailtodisk.exe"
因此它应该如下所示
。
mail.add_x_header=关闭
This works fine for me.It includes mail with image and a link and works for all sorts of mail ids. The clue is to use all the header perfectly.
If you are testing it from localhost, then set the below before checking:
How to set mail send from localhost xampp:
comment everything in
D:/xampp/sendmail/sendmail.ini
and mention the below under[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=your-mail-password
[email protected]
In
D:/xampp/php/php.ini
a. Under
[mail function]
SMTP = smtp.gmail.com
smtp_port = 587
b. set
sendmail_from = [email protected]
c. uncomment sendmail_path = "\"D:\xamp\sendmail\sendmail.exe\" -t"
Hence it should be look like below
d. comment sendmail_path="D:\xamp\mailtodisk\mailtodisk.exe"
Hence it should be look like below
e.
mail.add_x_header=Off