为什么我不应该使用 PHP 的 mail() 函数? [英] Why shouldn't I use PHP's mail() function?

查看:27
本文介绍了为什么我不应该使用 PHP 的 mail() 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用 PHP 发送电子邮件消息时,一般的观点是远离 PHP 的内置 mail() 函数并改用库.

The general opinion when it comes to sending email messages in PHP is to stay clear of PHP's built-in mail() function and to use a library instead.

我想知道的是在库或扩展上使用 mail() 的实际原因和缺陷.例如,标准mail() 调用中未包含的常用标头.

What I want to know are the actual reasons and flaws in using mail() over a library or extension. For example, the commonly specified headers that aren't included in a standard mail() call.

推荐答案

引用:

PHP mail() 函数的缺点

在某些情况下,邮件通过PHP mail() 没有收到收件人,尽管它是由 WB 发送的没有任何错误信息.最多该问题的常见原因是如下所列.

In some cases, mails send via PHP mail() did not receive the recipients although it was send by WB without any error message. The most common reasons for that issue are listed below.

  • 邮件标题或内容格式错误(例如,换行符的差异在 Windows/Unix 之间)
  • 发送邮件不在您的服务器上安装或配置(php.ini)
  • 邮件提供商recipeint 不允许通过以下方式发送邮件PHP mail();常见的垃圾邮件防护
  • wrong format of mail header or content (e.g. differences in line break between Windows/Unix)
  • sendmail not installed or configured on your server (php.ini)
  • the mail provider of the recipeint does not allow mails send by PHP mail(); common spam protection

标题格式错误或内容可能导致邮件被视为垃圾邮件.在最好的情况下,这样的邮件被转移到垃圾邮件收件人收件箱的文件夹或发送返回给发件人.在最坏的情况下,这些邮件被删除,没有任何评论.如果没有安装 sendmail或者没有配置,没有邮件可以发送.

Errors in the format of header or content can cause that mails are treated as SPAM. In the best case, such mails are transfered to the spam folder of your recipient inbox or send back to the sender. In the worst case, such mails are deleted without any comment. If sendmail is not installed or not configured, no mails can be send at all.

这是免费邮件的常见做法提供者,如 GMX,拒绝邮件通过 PHP 函数 mail() 发送.非常通常这样的邮件会被删除而没有收件人的任何信息.

It is common practice by free mail provider such as GMX, to reject mails send via the PHP function mail(). Very often such mails are deleted without any information of the recipient.

这篇关于为什么我不应该使用 PHP 的 mail() 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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