php PhpMailer 与 SwiftMailer?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/303783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PhpMailer vs. SwiftMailer?
提问by Paul Wicks
I'm building a fairly simple PHP script that will need to send some emails with attachments. I've found these 2 libraries to do this.
我正在构建一个相当简单的 PHP 脚本,需要发送一些带有附件的电子邮件。我找到了这两个库来做到这一点。
Does either one have significant advantages over the other? Or should I just pick one at random and be done with it?
任何一个都比另一个有明显的优势吗?或者我应该随机选择一个并完成它?
采纳答案by benlumley
I was going to say that PHPMailer is no longer developed, and Swift Mailer is. But when I googled ...
我想说 PHPMailer 不再被开发,而 Swift Mailer 是。但是当我用谷歌搜索...
https://github.com/PHPMailer/PHPMailer
https://github.com/PHPMailer/PHPMailer
That suggests its being worked on again.
这表明它正在再次工作。
I've used PHPMailer a lot, and its always been solid and reliable. I had recently started using Swift Mailer, for the above reason, and it too has given me no trouble.
我经常使用 PHPMailer,它一直很可靠。由于上述原因,我最近开始使用 Swift Mailer,它也没有给我带来任何麻烦。
Now that PHPMailer is developed again, I think I'll probably give the new version a try.
现在PHPMailer又开发出来了,我想我可能会尝试一下新版本。
So, my answer is that both are capable, and that it doesn't matter that much – choose one, learn it, use it. Both offer massive advantages over mail() and abstract away the nuances of email so that you can get on with whatever you are really trying to develop.
所以,我的答案是两者都有能力,而且没有那么重要——选择一个,学习它,使用它。两者都比 mail() 提供了巨大的优势,并抽象出电子邮件的细微差别,以便您可以继续进行真正尝试开发的内容。
回答by M A Hossain Tonu
Whatever the features are, they have variety in their applicable licenses:
无论功能是什么,它们的适用许可证都有多种:
PHPMailer - LGPL 2.1 (https://github.com/PHPMailer/PHPMailer)
PHPMailer - LGPL 2.1 ( https://github.com/PHPMailer/PHPMailer)
SwiftMailer - MIT license (https://github.com/swiftmailer/swiftmailer)
SwiftMailer - MIT 许可证 ( https://github.com/swiftmailer/swiftmailer)
回答by troelskn
回答by Sheldmandu
Having looked at both I think SwiftMailer has a much nicer interface than PHPMailer and as someone has pointed out Zend_Mail is also another good option especially if you're using other Zend components. It makes life much easier if you use everything from the same framework.
看过两者后,我认为 SwiftMailer 的界面比 PHPMailer 好得多,正如有人指出的那样,Zend_Mail 也是另一个不错的选择,尤其是在您使用其他 Zend 组件时。如果你使用同一个框架中的所有东西,它会让生活变得更容易。
回答by daremon
I've used PHPMailer on many projects and never had a problem. It's feature complete and it has good docs.
我在很多项目中使用过 PHPMailer,从来没有遇到过问题。它的功能齐全,并且有很好的文档。
I had never heard of Swiftmailer so I took a peek at the website. It seems a nice solution too.
我从未听说过 Swiftmailer,所以我看了一眼网站。这似乎也是一个不错的解决方案。
If your needs are simple as you say, then just pick one at random.
如果你的需求像你说的那么简单,那么随便挑一个就行了。
回答by Marco Demaio
Google trends: swiftmailer is growing but phpmailer is still very strong.
谷歌趋势:swiftmailer 正在增长但 phpmailer 仍然非常强大。
I would go with Swiftmailer because documentation is clear and easy. Phpmailer site/docs are a bit messy (at least they look so).
我会选择 Swiftmailer,因为文档清晰易懂。Phpmailer 站点/文档有点乱(至少看起来是这样)。
EDIT: after trying them both (and banging my head against an hosting issue for which SwiftMailer did not output any type of hint) I completely changed my mind, I would definitely go with PHPMailerfor at least one good reason: it's much easier to debug in the event you have any issue.
编辑:在尝试了它们之后(并在 SwiftMailer 没有输出任何类型的提示的托管问题上猛烈抨击我)我完全改变了主意,我肯定会使用 PHPMailer至少有一个很好的理由:调试要容易得多如果您有任何问题。
Both SwiftMailer and PHPMailer provide debug options (SwiftMailer with a plugin and PHPMailer by turning on SMTPDebug = 2), but SwiftMailer is made by hundreds of small files that make SwiftMailer more difficult to debug compared to the 3 files PHPMailer is made of.
SwiftMailer 和 PHPMailer 都提供调试选项(带有插件的 SwiftMailer 和通过打开 PHPMailer SMTPDebug = 2),但 SwiftMailer 由数百个小文件组成,与 PHPMailer 组成的 3 个文件相比,这使得 SwiftMailer 更难调试。
And about docs, the PHPmailer documentationis less fancy looking, but it has got all you need: simple tutorial, examples
关于文档,PHPmailer 文档看起来不那么花哨,但它有你需要的一切:简单的教程、示例
回答by user398341
I've just switched to Swift today due to the problems with PHPMailer and PHP 5.3 - even the latest version - which is a shame. Swift has a very well documented integration, which makes things easier.
由于 PHPMailer 和 PHP 5.3(甚至是最新版本)的问题,我今天刚刚切换到 Swift,这很遗憾。Swift 有一个很好的文档集成,这让事情变得更容易。

