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.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.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=4232013-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.com2013-08-16 10:46:51 1VAFgI-0006FP-UU Completed
PHP + Exim4 on Debian - mail does not get delivered
debian;php;sendmail;exim
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.