root can't send mail (apticron) but user can (mail/mailx)

5,542

Your remote mail server doesn't believe root@yourdomain in the SMTP envelope¹ is a valid email address, so it's refusing messages from you. And that's where apticron is trying to send from, so it doesn't work.

ssmtp allows you to override the default email address and relay on a per-user basis in the /etc/ssmtp/revaliases file. You can use this to set an acceptable (to your mail relay) address for root, by adding a line like:

root:EMAIL@DOMAIN:RELAY-HOST:RELAY-PORT

replacing the all-caps portions with email address and relay host you'd like to use.

Note: Much of this was from troubleshooting in chat, starting around this message.


1Note that the SMTP "envelope" sender is different than the From: field that shows up in your mail client. Though if you're lucky it's preserved in a different header.

Share:
5,542

Related videos on Youtube

toxefa
Author by

toxefa

Python, JS, Bash, Linux Systems

Updated on November 28, 2022

Comments

  • toxefa
    toxefa over 1 year
    • I'm running Debian
    • I've set up ssmtp as my MTA and this works perfectly
    • I can send mail using both mail and mailx with a standard user account

    BUT... When I run sudo apticron I get:

    send-mail: RCPT TO:<[user]@[mydomain].com> (550 Sender verify failed)
    

    Any ideas? (I've blanked the email details myself - that's not part of the error)


    UPDATE:

    When running mail or mailx as root, these break too! They only work when I run them under my standard user account.

    Error message I receive as root when running:

    echo "test" | mail -s "test" [user]@[mydomain].com 
    

    is same as with apticron:

    RCPT TO:[user]@[mydomain]> (550 Sender verify failed) 
    

    UPDATE 2:

    sudo mail -v etc... shows that the root user actually replaces the first part of the email address with 'root' despite /etc/ssmtp/ssmtp.conf specifying FromLineOverride=NO:

    [<-] 220 and/or bulk e-mail.
    [->] EHLO [user]@[mydomain].com
    [<-] 250 HELP
    [->] AUTH LOGIN
    [<-] 334 VXNlcm5hbWU6
    [->] [redacted Base64 username]
    [<-] 334 UGFzc3dvcmQ6
    [<-] 235 Authentication succeeded
    [->] MAIL FROM:<root@[mydomain.com]>
    [<-] 250 OK
    [->] RCPT TO:<[user]@[mydomain].com>
    [<-] 550 Sender verify failed
    send-mail: RCPT TO:<[user]@[mydomain].com> (550 Sender verify failed)
    

    EDIT:

    I've removed previously pasted code from apticron as clearly the problem lies with root not being able to send emails (this is no longer limited to an individual program)

    • derobert
      derobert about 9 years
      "sender verify" would sound like a problem with the from address. Not the recipient.
    • toxefa
      toxefa about 9 years
      That's what I thought originally.. I've tried 4 different from addresses, all of which work perfectly with command line mail and mailx. Incidentally I think having a dash/hyphen in the from address breaks ssmtp, that's why I changed it originally.
    • toxefa
      toxefa almost 9 years
      @derobert I still haven't manage to resolve this. Any other advice? How can it be that I can send emails without any problem when I do mail -s "something" [email protected] but apticron fails every time if they're both using the same MTA?
    • Alen Milakovic
      Alen Milakovic almost 9 years
      Try a different MTA - exim is generally well supported on Debian, and see if that helps you figure it out.
    • Alen Milakovic
      Alen Milakovic almost 9 years
      If you get an error, post it, If you don't get an error, that might tell you something too.