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. Does either one have significant advantages over the other? Or should I just pick one at random and be done with it?
问题:
回答1:
I was going to say that PHPMailer is no longer developed, and Swift Mailer is. But when I googled ...
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.
Now that PHPMailer is developed again, I think I'll probably give the new version a try.
回答2:
Whatever the features are, they have variety in their applicable licenses:
PHPMailer - LGPL 2.1 (https://github.com/PHPMailer/PHPMailer)
SwiftMailer - MIT license (https://github.com/swiftmailer/swiftmailer)
回答3:
There is also Zend_Mail. If I had to pick one for a new project today, I would seriously consider that.
回答4:
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.
回答5:
I've used PHPMailer on many projects and never had a problem. It's feature complete and it has good docs.
I had never heard of Swiftmailer so I took a peek at the website. It seems a nice solution too.
If your needs are simple as you say, then just pick one at random.
回答6:
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.
回答7:
Google trends: swiftmailer is growing but phpmailer is still very strong.
I would go with Swiftmailer because documentation is clear and easy. Phpmailer site/docs are a bit messy (at least they look so).
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 PHPMailer for at least one good reason: it's much easier to debug in the event you have any issue.
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.
And about docs, the PHPmailer documentation is less fancy looking, but it has got all you need: simple tutorial, examples