Difference between revisions of "User:Paul/sandbox/Transactional mail server"

From UNPM.org Wiki
Jump to navigation Jump to search
Line 9: Line 9:
 
== Transactional email via MTA ==
 
== Transactional email via MTA ==
  
Setting up an MTA for transactional email is actually very simple.
+
Log in as root and install the necessary packages:
  
  username@servername:~$ sudo aptitude install postfix opendkim opendkim-tools
+
  username@servername:~$ sudo -i
 +
root@servername:~# aptitude install postfix opendkim opendkim-tools
  
 
== SMTP mail server ==
 
== SMTP mail server ==

Revision as of 22:54, 18 November 2018

WARNING: This article is in a user sandbox, indicating it is a rough draft, and as such, is likely incomplete, contains buggy and insecure configurations, and is subject to substantial and frequent changes.

A transactional email is generated by many popular packages, typically for account registration confirmation, topic reply notifications, password retrieval, and other automated uses such as sending system notification messages to administrators. The emails will commonly be sent from an email address that is a non-functioning email account used exclusively for sending, such as NO-REPLY@example.com.

The PHP mail() function is typically the default method that PHP packages will use for sending transactional mail. This function will use the server's sendmail-compliant MTA to send the mail, thus necessitating a sendmail-compliant MTA to be installed. An MTA can be used to send mail directly from the server or can be configured to send mail through a smart host to reduce server and admin overhead.

Most of the popular PHP packages will include an option or have a plugin available to send transactional email through an SMTP server, eliminating the requirement to install any type of MTA for the purpose of supporting email generated by the package. However, without an MTA installed, system messages cannot be sent to the administrators.

Transactional email via MTA

Log in as root and install the necessary packages:

username@servername:~$ sudo -i
root@servername:~# aptitude install postfix opendkim opendkim-tools

SMTP mail server

This simple solution is most useful when delivering mail in small batches, but can create issues with large quantities of mail being sent at one time. When using this option it is best to choose a service that is intended to be used for sending transactional email. Most free email services (Gmail, Yahoo!, Hotmail, etc.) are not friendly to this type of usage and will often suspend accounts being used in this fashion. A better option is to use a service such as SendGrid or Mailgun. SendGrid offers up to 12,000 free emails per month while Mailgun offers 10,000 free emails per month, except for Rackspace customers, who get 50,000 free emails per month.

Nullmailer

Nullmailer is a lightweight sendmail compliant MTA for sending emails to smart hosts. Since the version in the Ubuntu 12.04 repositories is very outdated and doesn't support modern encryption, a back-port may be used instead:

username@servername:~$ sudo add-apt-repository ppa:unpm/nullmailer-backport
username@servername:~$ sudo aptitude update && sudo aptitude install nullmailer

Installing the PPA for Nullmailer from the unpm.org repository requires confirmation that insecure software may be installed. An explanation on how the PPA was configured is in the Create Back-port for PPA article.

Although the installer includes a guide that will automatically create the configuration files, it is better to go through each file after installation and verify it has been configured properly.

/etc/nullmailer/adminaddr

username@servername:~$ sudo nano /etc/nullmailer/adminaddr

The adminaddr file tells Nullmailer where to send failures and errors, so enter the appropriate email address in this file.

adminuser@adminexample.com

/etc/nullmailer/defaultdomain

username@servername:~$ sudo nano /etc/nullmailer/defaultdomain

Enter the default domain that Nullmailer will use to send emails from when no other domain is specified.

defaultexample.com

/etc/nullmailer/me

username@servername:~$ sudo nano /etc/nullmailer/me

This configuration file is not very well documented. Some online sources state to use \$hostname.example.com, but others report better experiences with \example.com.

/etc/nullmailer/remotes

username@servername:~$ sudo nano /etc/nullmailer/remotes

This is the file that contains login information for the the smart host and should be completed based on the configuration settings of the service being used.

Sendgrid
smtp.sendgrid.net smtp --port=587 --starttls --user=sendgridusername --pass=sendgridpassword
Mailgun
smtp.mailgun.org smtp --port=587 --starttls --user=mailgunaccountuser@mailgunaccountexample.com --pass=mailgunpassword
username@servername:~$ sudo service nullmailer reload


https://launchpad.net/~unpm/+archive/ubuntu/nullmailer-backport

http://opensourcehacker.com/2013/03/25/using-nullmailer-and-mandrill-for-your-ubuntu-linux-server-outboud-mail/

http://untroubled.org/nullmailer/

http://www.troubleshooters.com/linux/nullmailer/

External links

A Mailserver on Ubuntu 12.04: Postfix, Dovecot, MySQL | Ex Ratione

How to send one billion email messages per month

Postfix SOHO README standalone server