Class Features

  • Probably the world's most popular code for sending email from PHP!
  • Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more
  • Integrated SMTP support - send without a local mail server
  • Send emails with multiple To, CC, BCC and Reply-to addresses
  • Multipart/alternative emails for mail clients that do not read HTML email
  • Add attachments, including inline
  • Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
  • SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SSL and SMTP+STARTTLS transports
  • Validates email addresses automatically
  • Protect against header injection attacks
  • Error messages in over 50 languages!
  • DKIM and S/MIME signing support
  • Compatible with PHP 5.5 and later
  • Namespaced to prevent name clashes
  • Much more!

Why you might need it

Many PHP developers need to send email from their code. The only PHP function that supports this is mail(). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments.

Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong! Please don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own. Try SwiftMailerZend/MailZetaComponents etc.

The PHP mail() function usually sends via a local mail server, typically fronted by a sendmail binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.


This software is distributed under the LGPL 2.1 license, along with the GPL Cooperation Commitment. Please read LICENSE for information on the software availability and distribution.



  • 可能是全球最受欢迎的用于从PHP发送电子邮件的代码!
  • 已被许多开源项目使用:WordPress,Drupal,1CRM,SugarCRM,Yii和Joomla!还有很多
  • 集成的SMTP支持-在没有本地邮件服务器的情况下发送
  • 发送带有多个“收件人”,“抄送”,“密件抄送”和“回复”地址的电子邮件
  • 不阅读HTML电子邮件的邮件客户端的多部分/备用电子邮件
  • 添加附件,包括内联
  • 支持UTF-8内容以及8位,base64,二进制和带引号的可编码
  • 自动验证电子邮件地址
  • 防止标题注入攻击
  • 超过50种语言的错误消息!
  • DKIM和S / MIME签名支持
  • 与PHP 5.5及更高版本兼容
  • 命名空间以防止名称冲突
  • 多得多!



正确格式化电子邮件非常困难。有无数重叠的RFC,需要严格遵守极其复杂的格式和编码规则-您在网上会发现mail()直接使用该功能的绝大多数代码是完全错误的! 不要尝试自己动手做-如果您不使用PHPMailer,则在滚动自己的应用程序之前,还应该查看许多其他优秀的库。试试SwiftMailerZend / MailZetaComponents等。

PHP mail()函数通常通过本地邮件服务器发送,通常sendmail在Linux,BSD和macOS平台上以二进制文件开头,但是Windows通常不包括本地邮件服务器。PHPMailer的集成SMTP实现允许在Windows平台上发送电子邮件,而无需本地邮件服务器。


该软件与LGPL 合作承诺书一起在LGPL 2.1许可下分发。请阅读许可以获得有关软件可用性和发行的信息。

Fatal error: Uncaught Error: Call to undefined function create_function() in /www/wwwroot/ Stack trace: #0 /www/wwwroot/ autoptimizeStyles->read() #1 [internal function]: autoptimize_end_buffering() #2 /www/wwwroot/ ob_end_flush() #3 /www/wwwroot/ wp_ob_end_flush_all() #4 /www/wwwroot/ WP_Hook->apply_filters() #5 /www/wwwroot/ WP_Hook->do_action() #6 /www/wwwroot/ do_action() #7 [internal function]: shutdown_action_hook() #8 {main} thrown in /www/wwwroot/ on line 96