Difference between revisions of "Emails"

From wiki
m (format)
(Wording)
Line 1: Line 1:
Sending emails is important for a server. It allows the server to notify remote users (you) in can you need to do some action.
+
Sending emails is important for a server. It allows it to notify you of various events (update pending, task failure, breach attempt…).
  
 
This guide will show you two different configuration options:
 
This guide will show you two different configuration options:
* Send only: Simple configuration. The server uses an external SMTP server to send emails. It can't receive emails
+
* Send only: Simple configuration. The server uses an external SMTP server to send emails. Use this if you want to just receive notification emails from a server.
* Send and Receive: More complex configuration. It allows you to handle your complete email infrastructure.
+
* Complete: A complete email infrastructure with your own SMTP and IMAP server. Plus a webmail and the much needed spam filter.
  
== Send only ==
+
== Send Only ==
  
 
=== Install ===
 
=== Install ===
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
# apt install exim4-daemon-light bsd-mailx
+
$ sudo apt install exim4-daemon-light bsd-mailx
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 35: Line 35:
 
gmail-smtp-msa.l.google.com has address 74.125.206.109
 
gmail-smtp-msa.l.google.com has address 74.125.206.109
 
gmail-smtp-msa.l.google.com has IPv6 address 2a00:1450:400c:c04::6d
 
gmail-smtp-msa.l.google.com has IPv6 address 2a00:1450:400c:c04::6d
</syntaxhighlight>here you see on the first line that <code>smtp.gmail.com</code> is a CNAME to <code>gmail-smtp-msa.l.google.com</code>. In that case you can put <code>*.google.com</code> in the password file.
+
</syntaxhighlight>here you see on the first line that <code>smtp.gmail.com</code> is a CNAME (alias) to <code>gmail-smtp-msa.l.google.com</code>. In that case you can put <code>*.google.com</code> in the password file.
  
 
Finally, activate the new configuration using<syntaxhighlight lang="console">
 
Finally, activate the new configuration using<syntaxhighlight lang="console">
# service exim4 reload
+
$ sudo systemctl reload exim4.service
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 46: Line 46:
 
</syntaxhighlight>You should receive the email in your mailbox
 
</syntaxhighlight>You should receive the email in your mailbox
  
== Send and Receive ==
+
== Complete ==
Want to get rid of Google and have your private email be really private? Building your own mail server is the solution.
+
Want to get rid of Google and have your private emails be really private? Building your own mail server is the solution.
  
 
{{Warning}}Getting your own mail server is rewarding and fun, however it's harder and more time consuming than typical sysadmin tasks like installing a [[Nginx|webserver]]. If done incorrectly you risk loosing emails, being submerged by spams or being considered as spammer by others and not be able to send emails. That being said, I've been running my own mail server for almost a decade without any major issue.
 
{{Warning}}Getting your own mail server is rewarding and fun, however it's harder and more time consuming than typical sysadmin tasks like installing a [[Nginx|webserver]]. If done incorrectly you risk loosing emails, being submerged by spams or being considered as spammer by others and not be able to send emails. That being said, I've been running my own mail server for almost a decade without any major issue.

Revision as of 01:59, 8 January 2017

Sending emails is important for a server. It allows it to notify you of various events (update pending, task failure, breach attempt…).

This guide will show you two different configuration options:

  • Send only: Simple configuration. The server uses an external SMTP server to send emails. Use this if you want to just receive notification emails from a server.
  • Complete: A complete email infrastructure with your own SMTP and IMAP server. Plus a webmail and the much needed spam filter.

Send Only

Install

$ sudo apt install exim4-daemon-light bsd-mailx

Configure

Edit file /etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype='satellite'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1; ::1'
dc_readhost='example.org'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.example.org::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

Edit file /etc/exim4/passwd.client and add a line like

smtp.example.org:username:mYpa$$w0rd

Note: if smtp.example.org is a CNAME, you must use the destination of the CNAME in the passwd.client file.

$ host smtp.gmail.com
smtp.gmail.com is an alias for gmail-smtp-msa.l.google.com.
gmail-smtp-msa.l.google.com has address 74.125.206.108
gmail-smtp-msa.l.google.com has address 74.125.206.109
gmail-smtp-msa.l.google.com has IPv6 address 2a00:1450:400c:c04::6d

here you see on the first line that smtp.gmail.com is a CNAME (alias) to gmail-smtp-msa.l.google.com. In that case you can put *.google.com in the password file. Finally, activate the new configuration using

$ sudo systemctl reload exim4.service

Test

$ echo "test" | mailx -s "test" root

You should receive the email in your mailbox

Complete

Want to get rid of Google and have your private emails be really private? Building your own mail server is the solution.


Warning Warning: Getting your own mail server is rewarding and fun, however it's harder and more time consuming than typical sysadmin tasks like installing a webserver. If done incorrectly you risk loosing emails, being submerged by spams or being considered as spammer by others and not be able to send emails. That being said, I've been running my own mail server for almost a decade without any major issue.

To get a fully functional web server, you will need to go through these guides: