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 [email protected] to [email protected]).

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 [email protected] using -f
Sep 21 13:22:34 hostname sendmail[1648]: q8LDMYe9001648: [email protected], size=649, class=0, nrcpts=1, msgid=<[email protected]>, relay=www-data@localhost
Sep 21 13:22:34 hostname sm-mta[1649]: q8LDMYxB001649: from=<[email protected]>, size=1023, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 13:22:34 hostname sendmail[1648]: q8LDMYe9001648: [email protected], 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 [email protected] using -f
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgo001653: [email protected], size=465, class=0, nrcpts=1, msgid=<[email protected]>, relay=www-data@localhost
Sep 21 13:22:34 hostname sm-mta[1654]: q8LDMY0G001654: <[email protected]>... User unknown
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgo001653: [email protected], 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=<[email protected]>, 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: <[email protected]>... User unknown
Sep 21 13:22:34 hostname sendmail[1653]: q8LDMYgp001653: [email protected], 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=<[email protected]>, 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=<[email protected]>, 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: <[email protected]>... User unknown
  • I can't understand why Drupal's error says from [email protected] to [email protected]
  • 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=<[email protected]>, relay=root@localhost
Sep 21 16:00:07 hostname sm-mta[3305]: q8LG07FE003305: from=<[email protected]>, size=487, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 21 16:00:07 hostname sendmail[3283]: q8LFwxIS003283: [email protected], 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=<[email protected]>, ctladdr=<[email protected]> (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)
17
  • 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, 2012 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, 2012 at 16:07
  • Now we know the mail server works. For my second question does this email id [email protected] exist ??
    – junedkazi
    Sep 21, 2012 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, 2012 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, 2012 at 16:47

2 Answers 2

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:

    sudo sendmailconfig
    

Optionally reloaded the sendmail by:

service sendmail restart

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

1
  • 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, 2013 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.

2
  • 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, 2012 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, 2012 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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