5
*hostname.domain.com is substituted throughout for my actual subdomain*

My Setup

I have Drupal 7.14 on an OpenVZ VPS running Ubuntu 11.10 (also tested with 10.04). Ubuntu has installed the repository versions of Apache2/php5/mysql, (not the LAMP metapackage) with php5.ini configured to dump all error messages to syslog.

My Problem

Consistently, when the site is to send an email to any address, it returns:

Unable to send e-mail. Contact the site administrator if the problem persists.

And the Drupal Error in 'Recent log messages' readds:

Error sending e-mail (from noreply@hostname.domain.com to noreply@hostname.domain.com).

This Error shows in the Drupal logs no matter what address the email is being sent to.

The email does actually end up sending after a short delay. Usually 1 second, but also 6 or more seconds.

Contents of Syslog

Sep 21 13:22:34 hostname sendmail[1648]: q8LDMYe9001648: Authentication-Warning: hostname.domain.com: www-data set sender to noreply@hostname.domain.com using -f
Sep 21 13:22:34 hostname sendmail[1648]: q8LDMYe9001648: from=noreply@hostname.domain.com, size=649, class=0, nrcpts=1, msgid=<201209211322.q8LDMYe9001648@hostname.domain.com>, relay=www-data@localhost
Sep 21 13:22:34 hostname sm-mta[1649]: q8LDMYxB001649: from=<noreply@hostname.domain.com>, size=1023, class=0, nrcpts=1, msgid=<201209211322.q8LDMYe9001648@hostname.domain.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 13:22:34 hostname sendmail[1648]: q8LDMYe9001648: to=newuser@fakedomain.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30649, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8LDMYxB001649 Message accepted for delivery)
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgo001653: Authentication-Warning: hostname.domain.com: www-data set sender to noreply@hostname.domain.com using -f
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgo001653: from=noreply@hostname.domain.com, size=465, class=0, nrcpts=1, msgid=<201209211322.q8LDMYgo001653@hostname.domain.com>, relay=www-data@localhost
Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0G001654: <noreply@hostname.domain.com>... User unknown
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgo001653: to=noreply@hostname.domain.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30465, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0G001654: from=<noreply@hostname.domain.com>, size=465, class=0, nrcpts=0, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgo001653: q8LDMYgp001653: DSN: User unknown
Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0I001654: <noreply@hostname.domain.com>... User unknown
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgp001653: to=noreply@hostname.domain.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31489, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0I001654: from=<>, size=1489, class=0, nrcpts=0, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgp001653: q8LDMYgq001653: return to sender: User unknown
Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0K001654: from=<>, size=4700, class=0, nrcpts=1, msgid=<201209211322.q8LDMYgq001653@hostname.domain.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgq001653: to=postmaster, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32513, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8LDMY0K001654 Message accepted for delivery)
Sep 21 13:22:34 hostname sm-mta[1655]: q8LDMY0K001654: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=34947, dsn=2.0.0, stat=Sent
Sep 21 13:22:40 hostname sm-mta[1651]: q8LDMYxB001649: to=<newuser@fakedomain.com>, delay=00:00:06, xdelay=00:00:06, mailer=esmtp, pri=121023, relay=fakedomain.com. [86.48.74.19], dsn=2.0.0, stat=Sent (Ok)

Not Understood By Me

There are several seeming anomalies I do not understand, such as:

  • stat=User unknown
  • DSN: User unknown
  • Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0I001654: <noreply@hostname.domain.com>... User unknown
  • I can't understand why Drupal's error says from noreply@hostname.domain.com to noreply@hostname.domain.com
  • I can send mail from the command line using sendmail, and it goes through just fine:

Contents of mail.log after sending with the command line on root

Sep 21 16:00:07 hostname sendmail[3283]: q8LFwxIS003283: from=root, size=167, class=0, nrcpts=1, msgid=<201209211558.q8LFwxIS003283@hostname.domain.com>, relay=root@localhost
Sep 21 16:00:07 hostname sm-mta[3305]: q8LG07FE003305: from=<root@hostname.domain.com>, size=487, class=0, nrcpts=1, msgid=<201209211558.q8LFwxIS003283@hostname.domain.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 16:00:07 hostname sendmail[3283]: q8LFwxIS003283: to=gmail.account@gmail.com, ctladdr=root (0/0), delay=00:01:08, xdelay=00:00:00, mailer=relay, pri=30167, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8LG07FE003305 Message accepted for delivery)
Sep 21 16:00:08 hostname sm-mta[3307]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-RC4-SHA, bits=128/128
Sep 21 16:00:08 hostname sm-mta[3307]: q8LG07FE003305: to=<gmail.account@gmail.com>, ctladdr=<root@hostname.domain.com> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120487, relay=gmail-smtp-in.l.google.com. [74.125.142.26], dsn=2.0.0, stat=Sent (OK 1348243208 ut4si13805795igb.1)
  • 1
    There are 2 things to check a) IF the mail server is setup properly. b) Check if the email id exist – junedkazi Sep 21 '12 at 15:35
  • I can send mail through the command line using sendmail on the root account. I have updated the post with the mail.log contents when doing that. – bitfed Sep 21 '12 at 16:07
  • Now we know the mail server works. For my second question does this email id noreply@hostname.domain.com exist ?? – junedkazi Sep 21 '12 at 16:10
  • I'm sorry, I don't actually know where to look for or create email ids. (Which means that could be my problem, since all emails except for emails from root@ end up in everyones spam accounts). Where should I start? – bitfed Sep 21 '12 at 16:20
  • 1
    Just try and setup a new linux user on the system with the above email id and then try if it works – junedkazi Sep 21 '12 at 16:47
5

This error appeared after I've changed my host name from webserver to webserver.com, thus anything sent to *@webserver.com confused sendmail, as it's been searching local user with such name.

Adding a local user won't solve the problem completely, because if you try adding user like firstname.lastname, Linux system will complain.

What I've done though to fix my system, is configuring sendmail properly:

1) Modify /etc/mail/sendmail.mc by adding following lines to the very end:

define('MAIL_HUB', 'webserver.com.');
define('LOCAL_RELAY', 'webserver.com.');

2) Run:

sendmail config

Optionally reloaded the sendmail by:

service sendmail restart

On some Linux distributions (such as Ubuntu) it may be reloaded automatically.

  • I haven't tested this yet, but had finally arrived at the conclusion that this was related to the host name. This sounds about right, I hadno idea how to set it though, will update after trying this. – bitfed Oct 19 '13 at 20:17
1

I still do not understand why, but creating a linux user on my Ubuntu VPS named "noreply" fixed this issue. I am happy it works, but would appreciate an answer from anyone who might have insight or an alternative solution other than creating new linux users for every email id I want to send from.

Special thanks to junedkazi for discussing this with me in comments.

  • Also not really sure why this question doesn't deserve credit while some of the others I've seen are practically useless. Oh well. :-) – bitfed Sep 22 '12 at 9:17
  • maybe because this is a sendmail (serverfault.com) question and it doesn't really belong on the drupal site? Anyway sendmail needs a user per account by default to store it's email in ( not sure you can change that ) so that why you needed to create the unix user. – FLY Dec 5 '12 at 13:46

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.