Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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? –  Dušan Rychnovský 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. –  Dušan Rychnovský Aug 16 '13 at 9:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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