Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Sendmail Using Nullmailer and a Gmail Account on a Linux Server

DZone's Guide to

Sendmail Using Nullmailer and a Gmail Account on a Linux Server

· DevOps Zone
Free Resource

Download “The DevOps Journey - From Waterfall to Continuous Delivery” to learn learn about the importance of integrating automated testing into the DevOps workflow, brought to you in partnership with Sauce Labs.

When you run VPS servers or other “low end” boxes it is common scenario need to setup a outgoing email mail transfer agent to get reports from cron jobs or enable PHP scripts to send email.

Linux offers some really heavy weight options for sending email, including SendmailPostfixand Exim4. However, if you are a low end box user, you run low end services of which requirements are likely to send one email per month from your puny cron job or web contact form. This makes the options above

  • Plain scary
  • Very difficult to configure, maintain, due to extra complexity not necessary for your use case
  • Open some attack surface
  • You still need a master SMTP where you push forward your email messages

They don’t scale down.

Meet NullmailerNullmailer is a simple MTA (mail transfer agent) and sendmail command provider which simply dumps your email output forward to SMTP service.

But that’s not all. If you are using low end boxes you probably don’t need good SMTP service from your VPS provider  (spam makes them expensive to provide). So, here is the trick: you are probably using already a free web email provider like gmail, Hotmail or whatever happens to be the dominating internet company of the day. Nullmailer can be configured to use authenticated SMTP sending through any email provider quite easily.

Below is a setup script for Ubuntu / Debian (tested on Ubuntu 12.04 LTS) which setupsxinetd tunnel to connect to GMail’s smtp.google.com and send emails as your authenticated Gmail user. The orignal idea is described in this blog post by Jon Spriggs.

The downside of this hacky solution include

  • No real email From addresses: all email is aliased to your authentcated SMTP user
  • SMTP user password is stored on the server as plain text, so you probably want to create a rogue gmail user for this
  • No locally buffered email (not sure about this with Nullmailer?) – if SMTP acts strangely be prepared for major screw up
  • Using sendmail command with this solution may cause delays and other issues in the script (not sure how timeouting is handled with Nullmailer?)

The script is also available on Github, hosted inside ZtaneSH project. Please contribute your changes back on Github in a case you come across of improvements.

Nothing else is needed, except running the script as instructed.

Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure, brought to you in partnership with Sauce Labs

Topics:

Published at DZone with permission of Mikko Ohtamaa, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}