Question

I am new to PHP and I am not sure which email library I should use. I have read about PHPMailer, SwiftMail and the PEAR library.

I require

  • SMTP authentication
  • Send as html
  • Add attachments

Can anyone tell me which library is best?

Another question: is there a mail library which supports sending mail in a background queue?

Was it helpful?

Solution

SwiftMailer developed by Chris Corbyn of devnetwork forums :)

OTHER TIPS

SwiftMailer or PHPMailer are good libraries for sending out emails and both contain methods for HTML and attachments. PHPMailer is slightly on the lighter side in terms of file size.

As for your background queues question. I am using a combination of Gearman (PHP man page) and Redis in an application I am writing at the moment. If your requirements are less heavy duty then you could always make use of the Linux at queue to send out your emails. I have written a PHP wrapper class for the at binary so that could do this easily from PHP. See https://github.com/treffynnon/PHP-at-Job-Queue-Wrapper

Using at will also allow you to schedule a particular send out in the future. This is something that Gearman is currently unable to do on its own as I discovered in my question Schedule a job in Gearman for a specific date and time.

If you were thinking of going with PHPMailer, you might want to look at PostageApp, which has a very simple and easy to use API (Used it on one of my projects!) and can do just about everything you are looking for.

In addition, you can design templates and add the content with an API call. I really like this because it automatically in-lines HTML and CSS into the body of the email.

Let me know if you have any questions!

(Full Disclosure: I'm the Product Manager for PostageApp!)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top