Sending email from localhost

  • strict warning: Non-static method view::load() should not be called statically in /home/john567/drupalganger.com/sites/all/modules/views/views.module on line 843.
  • strict warning: Declaration of views_plugin_display::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/plugins/views_plugin_display.inc on line 1877.
  • strict warning: Declaration of views_plugin_display_page::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/plugins/views_plugin_display_page.inc on line 481.
  • strict warning: Declaration of views_plugin_display_block::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/plugins/views_plugin_display_block.inc on line 193.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • strict warning: Declaration of views_handler_argument_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_argument.inc on line 770.
  • strict warning: Declaration of views_handler_sort_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_sort.inc on line 82.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • strict warning: Declaration of views_handler_filter_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 609.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/john567/drupalganger.com/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 128.

I have recently used Simplenews  module to publish and send newsletters to lists of subscribers.  Simplenews has a feature to send an email to a test user, I wanted to use this to see exactly how the newletters would look.  I do much of my development from a local machine and I found that my test emails from my local machine were being incorrectly categorized as spam.  Basically I couldn't receive any email which I sent.

 

 I looked at my mail.log file to see the exact details of what was happening. Below is a section of what I found:

 

....to=<test@example.com>, relay=mx1.balanced.blingy.mail.example.com[208.108.38.62]:25, delay=1.5, delays=0.33/0.05/0.94/0.17, dsn=5.0.0, status=bounced (host mx1.balanced.blingy.mail.example.com[208.108.38.62] said: 554 Service unavailable; Client host [67.172.156.140] blocked using zen.dnsbl; http://www.spamhaus.org/query/bl?ip=67.172.156.140 (in reply to RCPT TO command))...

 

I spent a few hours seaching on the internet for a way that I could send email from my localhost without having it bounce back as spam. A friend pointed my to this information from page 9 of the MAMP manual:

 

Smart Host: Many spam filters will identify emails sent through dynamic IPs as spam. To avoid this, you can select a SMTP server with static IP that will cover the
actual sending process of the email for you.
 

 

This was very helpful because it helped move me toward a fix.  After a lot of searching  and trial and error I finally came to a solution. I didn't hit too many deadends along the way either, which was nice.

 The solution was to change the configuration of my local postfix installation.  These are configured in the file /private/etc/postfix/main.cf and they affect how email is handled from my local machine.  I added the following four lines to the end of my main.cf file

 mydomain = dev.example.com
myhostname =dev.example.com
myorigin = $mydomain
relayhost = [smtp.comcast.net]

After making this change I have had no problems sending Simplenew test emails from my local machine and they are no longer categories as spam.  I have been receiving the test emails in less than one minute. Once I'm satisified that the test email renders as expected I migrate my newletter to a hosted webserver.

 * the actual URLs that I worked with have been replaced with example.com above