Question
How to get sendmail to send mail?
I’ve been happily beavering away on a Centos 7 droplet. I set up a LAMP stack and got few websites running in virtual hosts. I’ve now run into an annoying issue: the php mail() function isn’t working.
As a test I installed Drupal 7 on one of the sites. At first the form was submitted instantly but nothing was sent. After installing sendmail the form hangs for a while and I’m getting this in /var/log/maillog:
Jul 16 22:58:29 myhostname sendmail[18792]: My unqualified host name (myhostname) unknown; sleeping for retry
Jul 16 22:59:29 myhostname sendmail[18792]: unable to qualify my own domain name (myhostname) -- using short name
Jul 16 22:59:29 myhostname sendmail[18792]: alias database /etc/aliases rebuilt by myusername
Jul 16 22:59:29 myhostname sendmail[18792]: /etc/aliases: 76 aliases, longest 10 bytes, 771 bytes total
Jul 16 23:02:21 myhostname sendmail[18838]: My unqualified host name (myhostname) unknown; sleeping for retry
Jul 16 23:03:21 myhostname sendmail[18838]: unable to qualify my own domain name (myhostname) -- using short name
Jul 16 23:03:23 myhostname sendmail[18838]: My unqualified host name (myhostname) unknown; sleeping for retry
Jul 16 23:04:23 myhostname sendmail[18838]: unable to qualify my own domain name (myhostname) -- using short name
Jul 16 23:04:23 myhostname sendmail[18838]: w6GM3LxY018838: Authentication-Warning: myhostname: apache set sender to recipient@example.com using -f
Jul 16 23:04:23 myhostname sendmail[18838]: w6GM3LxY018838: from=recipient@example.com, size=429, class=0, nrcpts=1, msgid=<201807162203.w6GM3LxY018838@myhostname>, relay=apache@localhost
Jul 16 23:04:23 myhostname sendmail[18838]: w6GM3LxY018838: to=recipient@example.com, ctladdr=recipient@example.com (48/48), delay=00:01:02, xdelay=00:00:00, mailer=relay, pri=30429, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
I then added this to the /etc/httpd/sites-available/example.com.conf file:
<Directory /var/www/example.com/public_html>
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebsite@example.com"
</Directory>
That results in:
Jul 17 12:06:48 myhostname sendmail[20949]: My unqualified host name (myhostname) unknown; sleeping for retry
Jul 17 12:07:48 myhostname sendmail[20949]: unable to qualify my own domain name (myhostname) -- using short name
Jul 17 12:07:48 myhostname sendmail[20949]: My unqualified host name (myhostname) unknown; sleeping for retry
Jul 17 12:08:48 myhostname sendmail[20949]: unable to qualify my own domain name (myhostname) -- using short name
Jul 17 12:08:48 myhostname sendmail[20949]: w6HB7mFh020949: Authentication-Warning: myhostname: apache set sender to website@example.com using -f
Jul 17 12:08:50 myhostname sendmail[20949]: w6HB7mFh020949: from=website@example.com, size=476, class=0, nrcpts=1, msgid=<201807171107.w6HB7mFh020949@myhostname>, relay=apache@localhost
Jul 17 12:08:50 myhostname sendmail[20949]: w6HB7mFh020949: to=myvps@email.com, ctladdr=website@example.com (48/48), delay=00:01:02, xdelay=00:00:00, mailer=relay, pri=30476, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
I suspect the issue is my /etc/hosts and/or /etc/mail/local-host-names file but I’m at a loss at this stage.
# cat /etc/hosts
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 myhostname myhostname
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
# The following lines are desirable for IPv6 capable hosts
::1 myhostname myhostname
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
# cat /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
Any guidance gratefully received!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×