We had a need to send HTML formatted mail from a Drupal 7 site. We did some quick research and found the Mail system and HTML mail modules. We enabled the modules and configured them and figured We were done.
My colleague came back to me and told me that now, not only was the mail not sending as HTML, it wasn't sending at all!
Some research brought us to Using HTML Mail together with SMTP Authentication Support -- excellent!
We followed the steps in the tutorial and after creating the HTML mail / SMTP auth class we received a PHP error stating that Drupal had failed to load the class.
When you use the Mail system module to create a new class, behind the scenes it actually creates a new PHP (.inc) file and stores it in your sites /mailsystem/filename.inc . Unfortunately the file directory for the site I'm working on is outside of the Drupal root, and not easily accessible to the class loader. Along with this, we use a git deployment workflow, and the files directory is not version controlled.
Solution
We first grabbed a copy of the auto-generated file from the server, and then deleted the copy on the server. Then we added that file to a custom module using the files[] directive in the module's .info file (this tells Drupal to load the class). Finally we had to remove the existing entry for the file from the registry table of the database, making sure to remove the correct file, and that I had the generating module "mailsystem" as a WHERE clause.
Now we have a mail system class that does HTML formatting and SMTP authenticated delivery working with the appropriate modules, and it's version controlled too.
Thanks
Devaraj
Senior Developer
Group FMG
Copied verbatim from http://zufelt.ca/blog/how-send-html-mail-using-smtp-authentication-drupal
ReplyDelete