PHPMailer and A Refined Template

Matt Croak Code
5 min readAug 15, 2018

In the past I wrote about Action Mailer, a Ruby resource for email templating, development, and deployment. I am still a proponent of Action Mailer if you’re trying to find a solution to your Rails app email capability. I have not used Ruby or Rails much over the last 6 months or so (aside from some quick API needs), as for my job I’ve been working heavily with PHP.

While syntactically heavy, I’ve found PHP to be pretty robust. And PHPMailer is a great addition to the many PHP libraries available.

Before I continue, I would like to point out that this post is not in any way denouncing Action Mailer. I do still like Action Mailer and I do think Rails itself is pretty robust as frameworks go. It’s just that the months that I haven’t been using much of Rails are the months that I have been delving into and learning much of PHP. If your question is do I prefer Ruby or Ruby on Rails as opposed to PHP, then I am not prepared to answer as I am biased. I have been pretty much forced to prefer PHP since that’s what my company has been using. I like PHP. I like Ruby on Rails. It’s all about preference and exposure.

If you’ve been working more with Rails and prefer Ruby as opposed to PHP, then use Action Mailer. If you’re more familiar with PHP, use PHPMailer. Web Development produces the best results when a programmer works with whatever language or framework they are most comfortable with. If a job calls for you to learn something else, learn it. You don’t need to entirely abandon a language or framework that you respect and feel comfortable using. At the same time, don’t limit yourself with what feels safe. Keep evolving, keeping innovating, and above all keep developing.

Back to PHPMailer.

In PHP, there is a built-in function that you can use, called mail() that can create an electronic mail object and send said object to the recipient. You don’t need any library to execute it. You can simply call mail() like so:

--

--