Difference between revisions of "Emails/Send"
(Extract from parent page) |
(Add intro after page extract) |
||
Line 1: | Line 1: | ||
− | === Install | + | This page show how to send emails from a server by connecting to an external SMTP server. |
+ | |||
+ | As a alternative, you can also check the [[Emails/Complete|complete guide on how to build an email server]]. | ||
+ | |||
+ | == Prerequisite == | ||
+ | You will need a SMTP server to send the email. The one of your regular email address will work perfectly. | ||
+ | {{DISPLAYTITLE:Hot to send emails from server}} | ||
+ | |||
+ | == Install == | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
$ sudo apt install exim4-daemon-light bsd-mailx | $ sudo apt install exim4-daemon-light bsd-mailx | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | == Configure == | |
Edit file <code>/etc/exim4/update-exim4.conf.conf</code><syntaxhighlight lang="ini"> | Edit file <code>/etc/exim4/update-exim4.conf.conf</code><syntaxhighlight lang="ini"> | ||
dc_eximconfig_configtype='satellite' | dc_eximconfig_configtype='satellite' | ||
Line 19: | Line 27: | ||
dc_mailname_in_oh='true' | dc_mailname_in_oh='true' | ||
dc_localdelivery='mail_spool' | dc_localdelivery='mail_spool' | ||
− | </syntaxhighlight>Edit file <code>/etc/exim4/passwd.client</code> and add a line like<syntaxhighlight lang="properties"> | + | </syntaxhighlight>The line <code>dc_smarthost</code> need to be updated with the name of port of the smtp server that you will use. |
+ | |||
+ | Edit file <code>/etc/exim4/passwd.client</code> and add a line like<syntaxhighlight lang="properties"> | ||
smtp.example.org:username:mYpa$$w0rd | smtp.example.org:username:mYpa$$w0rd | ||
</syntaxhighlight>'''Note:''' if <code>smtp.example.org</code> is a CNAME, you must use the destination of the CNAME in the <code>passwd.client</code> file.<syntaxhighlight lang="console"> | </syntaxhighlight>'''Note:''' if <code>smtp.example.org</code> is a CNAME, you must use the destination of the CNAME in the <code>passwd.client</code> file.<syntaxhighlight lang="console"> | ||
Line 33: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | == Test == | |
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
− | $ echo " | + | $ echo "body" | mailx -s "subject" address@example.org |
</syntaxhighlight>You should receive the email in your mailbox | </syntaxhighlight>You should receive the email in your mailbox | ||
+ | [[Category:Email Server]] | ||
+ | [[Category:Linux Server]] |
Revision as of 05:52, 5 April 2017
This page show how to send emails from a server by connecting to an external SMTP server.
As a alternative, you can also check the complete guide on how to build an email server.
Prerequisite
You will need a SMTP server to send the email. The one of your regular email address will work perfectly.
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'
The line dc_smarthost
need to be updated with the name of port of the smtp server that you will use.
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 "body" | mailx -s "subject" address@example.org
You should receive the email in your mailbox