Difference between revisions of "Email relay"

Line 6: Line 6:
 
Our server will forward all emails to another SMTP server. The SMTP server we're gonna install is stupid: only local domain, no account checking, no anti-virus or spam protection.  
 
Our server will forward all emails to another SMTP server. The SMTP server we're gonna install is stupid: only local domain, no account checking, no anti-virus or spam protection.  
  
# From main SMTP server ("Gmail", "Outlook", ...) all emails come from the same account.
 
 
# From a local point of view, all emails are send using Linux default configuration and system users
 
# From a local point of view, all emails are send using Linux default configuration and system users
 +
# From the other hand - the big SMTP server ("Gmail", "Outlook", ...) - all emails come from the same account
  
  
Line 16: Line 16:
  
 
As you can see, POSTFIX SMTP server will just act as a proxy between local services and Gmail.
 
As you can see, POSTFIX SMTP server will just act as a proxy between local services and Gmail.
 +
 +
 +
 +
 +
=When to use it ?=
 +
 +
If you only have a single server and want to monitor it, then use a relay! That's much easier than setup a complete email server. It's also easier to maintain!
 +
 +
 +
 +
 +
 +
=Installation=
 +
 +
apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
 +
 +
 +
Edit Postfix configuration
 +
 +
 +
 +
 +
Set SMTP relay and SASL settings
 +
 +
 +
 +
 +
 +
Create login / password file
 +
vim /etc/postfix/sasl_password
 +
 +
 +
Put the following content
 +
[smtp.gmail.com]:587    USERNAME@gmail.com:PASSWORD
 +
 +
 +
Set rights
 +
chmod 640 /etc/postfix/sasl_password
 +
chown postfix:postfix /etc/postfix/sasl_password
 +
 +
 +
Compute new hash for postfix
 +
chown -R postfix /etc/postfix
 +
postmap /etc/postfix/sasl_password
 +
 +
 +
Create TLS policy file
 +
vim /etc/postfix/tls_policy
 +
 +
 +
Put the following content
 +
[smtp.gmail.com]:587 encrypt
 +
 +
 +
Compute new hash for postfix
 +
postmap /etc/postfix/tls_policy
 +
 +
 +
Test you configuration
 +
 +
 +
 +
Check your logs!
 +
 +
cat /var/log/mail.log
 +
 +
cat /var/log/mail.err
 +
 +
 +
 +
 +
 +
 +
 +
=Sources=

Revision as of 10:15, 13 August 2014


Principle

Our server will forward all emails to another SMTP server. The SMTP server we're gonna install is stupid: only local domain, no account checking, no anti-virus or spam protection.

  1. From a local point of view, all emails are send using Linux default configuration and system users
  2. From the other hand - the big SMTP server ("Gmail", "Outlook", ...) - all emails come from the same account


Principle:

SMTP server relay


As you can see, POSTFIX SMTP server will just act as a proxy between local services and Gmail.



When to use it ?

If you only have a single server and want to monitor it, then use a relay! That's much easier than setup a complete email server. It's also easier to maintain!



Installation

apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules


Edit Postfix configuration



Set SMTP relay and SASL settings



Create login / password file vim /etc/postfix/sasl_password


Put the following content [smtp.gmail.com]:587 USERNAME@gmail.com:PASSWORD


Set rights chmod 640 /etc/postfix/sasl_password chown postfix:postfix /etc/postfix/sasl_password


Compute new hash for postfix chown -R postfix /etc/postfix postmap /etc/postfix/sasl_password


Create TLS policy file vim /etc/postfix/tls_policy


Put the following content [smtp.gmail.com]:587 encrypt


Compute new hash for postfix postmap /etc/postfix/tls_policy


Test you configuration


Check your logs!

cat /var/log/mail.log

cat /var/log/mail.err




Sources