25

I'd like my cronjobs to be able to send mail from my home computer. My servers configure exim4 like this:

dc_eximconfig_configtype='internet'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

However, at home, my ISP blocks mail sent directly via a firewall. I have a password proteced ssl smtp server that I could route the mail through, but I have been unsuccessful in figuring out how to configure exim4 to make this work. I'm hoping somebody can give me a configuration example where I can plug in the host name, user name, password, and "use ssl" to get it to send mail through a single smtp server.

4 Answers 4

34

I finally found a detailed set of instructions by Tony Scelfo that actually work. It appears that you have to use transport layer security (TLS) on port 587. I have not gotten SSL SMTP to work.

First run sudo dpkg-reconfigure exim4-config and use these config options:

  • General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
  • System mail name: <your hostname>
  • IP-address to listen on for incoming SMTP connections: 127.0.0.1
  • Other destinations for which mail is accepted: <your hostname>
  • Machines to relay mail for: <leave this blank>
  • IP address or host name of the outgoing smarthost: mail.example.com::587
  • Hide local mail name in outgoing mail?
    • Yes - all outgoing mail will appear to come from your gmail account
    • No - mail sent with a valid sender name header will keep the sender’s name
  • Keep number of DNS-queries minimal (Dial-on-Demand)? No
  • Delivery method for local mail: <choose the one you prefer>
  • Split configuration file into small files? Yes (you need to edit one of the files next)

Then run sudo vi /etc/exim4/passwd.client and add the following lines for your mail host, and any aliases it has (found through nslookup). Substitute <email address> and <password> with the account you want to route mail through):

mail.example.com:<email address>:<password>
mail.yourhosting.provider:<email address>:<password>

Once you edit the passwd.client file, run sudo update-exim4.conf which will integrate your changes into your Exim4 config.

Run sudo /etc/init.d/exim4 restart and make sure that the service stops and starts properly. If the service is unable to restart, something probably went wrong when you edited the passwd.client file.

If Exim4 restarted, go ahead and run sudo tail -f /var/log/exim4/mainlog to watch the mail logs. In a different window, send an email from your system and make sure that you see a record go by withR=smarthost T=remote_smtp_smarthost H=gmail-smtp-msa.l.google.com ... X=TLS-1.0:RSA_ARCFOUR_MD5:16 in it. The X=TLS means that the mail is being sent with transport layer security which is what you want.

6
  • 3
    No need to "split configuration file into small files" since /etc/exim4/passwd.client is a separate file either way.
    – Run CMD
    Nov 9, 2015 at 17:08
  • Please note that specifying the SMTP port may not work with all mail servers. But exim4 will use TLS anyway with the default SMTP port if the mailserver offers it. It can be checked looking at the X= information in /var/log/exim4/mainlog
    – Run CMD
    Nov 10, 2015 at 8:43
  • Please, just point me to the correct direction. I don't want to duplicate some question. What if I want to all users to set their own stmp passwords in their HOME directories? Will exim4 look for various passwd.client? Tx
    – DrBeco
    Apr 28, 2016 at 1:38
  • That sounds like a new question to me Apr 28, 2016 at 1:46
  • @DrBeco If you have a specific question that is not specific to this question or answer, please ask it as a question.
    – Thomas Ward
    Aug 11, 2016 at 1:39
8

If your ISP requires authentication, you should set dc_smarthost to the mail server hostname and port combination your ISP uses, and dc_eximconfig_configtype to "smarthost" like so:

dc_eximconfig_configtype='smarthost'
dc_smarthost='mail.example.com::587'

Then, you can add your credentials to /etc/exim4/passwd.client like so:

mail.example.com:username:password

Then, any mail sent via your exim4 server will be routed through this mail host.

2
  • 12
    In update-exim4.conf I put in two colons for the smarthost line, as in dc_smarthost='mail.example.com::587' and it made all the difference! Finally started sending mail through.
    – Marcos
    Nov 6, 2012 at 22:44
  • +1 This is a very common mistake I've seen on many tutorials.
    – TwystO
    Mar 2, 2016 at 8:33
4

This works very well for me. My ISP uses port 25 and dc_smarthost='myisp.mail.server:25' after changing this files and issue commands:

  1. update-exim4.conf
  2. /etc/init.d/exim4 restart

After I made a test to send an email through exim4 classic sample like:

echo "content of mail body with pt-br chars ação avião língua é essa em 1609." | mail -s "Confirmar 16DOM" my-user-in-isp@my-domain-url

And these flow ok to inbox of my-user in my-domain-url.

0

The server-name in /etc/exim4/passwd.client have to be the canonical name after the name-resolution

example for:

dc_smarthost='securesmtp.t-online.de::587'

it is the value sfwdallmx.t-online.de from :

$ nslookup securesmtp.t-online.de
...
Non-authoritative answer:
Name:   securesmtp.t-online.de
Address: 194.25.134.110
Name:   securesmtp.t-online.de
Address: 194.25.134.46
securesmtp.t-online.de  canonical name = sfwdallmx.t-online.de.

The file passwd.client looks like:

sfwdallmx.t-online.de:user:pwd

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .