Make confirmation emails from simplenews obey newsletter settings
Simplenews is one of the solid Newsletter management modules for Drupal. It allows a Drupal site to have multiple newsletters at once, nodes can be sent out as newsletter to multiple recipients on a single cron run. It plays well with HTML emails as well with Editors like WYSIWYG, Drupal mail system and other contrib modules like Mime Mail. Besides these, it allows to have specific sender name and email address per newsletter.
But the sign up and opt out confirmation email doesn't obey the sender information settings, perhaps this is by design of the module but not quite right with respect to our requirements. This blog tries to provide a simple fix for the same using Drupal's standard mail system hook.
Though we configure each newsletter in "admin/config/services/simplenews/categories/%/edit" to have specific sender name and email address, it always takes the sender name and email address from "admin/config/services/simplenews/settings" which is the global details for all the newsletters.
So to avoid this, we need to use hook_mail_alter(). The following simple code snippet will give the solution to this problem,
- Replacing lengthy URLs in simplenews newsletter email with Bit.ly short URLs
- Leveraging CKeditor template to theme Drupal contents
- Creating horizontal form tabs in Drupal 7
- How we managed to send 75k emails per hour
- Drupal 7 Form API- Using #states on #markup field
- Best way to add new columns to custom table