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

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

问题描述

在PHP中发送电子邮件的一般意见是保持PHP内置的 mail()功能,并使用库。



我想知道的是在库或扩展名中使用 mail()的实际原因和缺陷。例如,通常指定的标头不包含在标准的 mail()调用中。

解决方案

报价


PHP的缺点 mail()功能



在某些情况下,邮件通过
发送PHP mail()没有收到
收件人,尽管是由WB
发送没有任何错误信息。

$ b
  • 邮件头或内容的错误格式
    $ b最常见的原因是
    。 $ b(例如Windows / Unix之间的换行符
    的差异)

  • sendmail不是
    在您的服务器上安装或配置
    (php.ini)


  • 的菜单邮件提供者不允许邮件发送
    PHP mail();常见的垃圾邮件保护



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



    通常的做法是免费邮件
    提供者,如GMX,拒绝邮件
    发送通过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.

    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.

    解决方案

    Quoting:

    Disadvantages of the PHP mail() function

    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.

    • 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

    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.

    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天全站免登陆