I have a fresh Debian installation with LAMP. There is a PHP script that sends email messages to arbitrary addresses using the mail function, but it does not work - the messages don't get delivered.

I have been searching the internet for quite a while and found out that there already is a SMTP server installed by default on Debian - the exim4 package. So I tried the following things so far.

  1. Launch the dpkg-reconfigure exim4-config command and choose the internet site; mail is sent and received directly using SMTP option. Follow the wizard and set the default options.
  2. Edit the /etc/php5/apache2/php.ini file and add the sendmail_path = /usr/sbin/sendmail -t line on the appropriate spot.

None of those things have helped. When I try to send emails to my testing GMail address, it is not delivered, even though the address otherwise works fine.

The following lines appear in my /var/log/exim4/mainlog file everytime I try to send an email.

2013-08-16 10:46:51 1VAFgI-0006FP-UU <= www-data@vps02.4jt.eu U=www-data P=local S=423
2013-08-16 10:46:51 1VAFgI-0006FP-UU => dusan@jezek.biz R=dnslookup T=remote_smtp H=aspmx.l.google.com [2a00:1450:4001:c02::1b] X=TLS1.2:RSA_ARCFOUR_SHA1:128 DN="C=US,ST=California,L=Mountain View,O=Google Inc,CN=mx.google.com"
2013-08-16 10:46:51 1VAFgI-0006FP-UU Completed

You need to configure exim4 to relay as a smarthost. There are a (lengthy) set of instructions here at the Debian wiki: GmailAndExim4, but it's really easy to get up and running. Your PHP sendmail_path is good to go.

  • What if I didn't won't it to run in the smart host mode, but as a standalone SMTP server (i.e. the internet site option)? Would that be possible? Aug 16 '13 at 9:42
  • In that case you'd need to set up exim as a full-blown smtp relay server (presumably) locked down to allow only actual system users on localhost to relay. I'm only familiar with setting up exim as a smarthost, so you'll need to read a guide on how to set it up. There is no "quick fix" answer for setting up a smtp relay server. Also, if you go that route you'll need to configure reverse dns on your server so sent mail isn't dropped as spam by receiving servers.
    – Jeff
    Aug 16 '13 at 9:50
  • OK, I'll go with the smarthost then. Thanks for your help. Aug 16 '13 at 9:56
  • 1
    No you DON'T need to configure exim4 as a smarthost. The "internet site; ..." configuration is fine. With no relying and listening only to (and ::1 if you have ipv6). I myself have it set up this way and it works. So I don't know the answer but this answer is definitely wrong (at least the part that says "you need to").
    – matteo
    Oct 22 '14 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.