Email Sent via [email protected] despite modifying /etc/aliases

7,019

There is no default return e-mail address other than the user name combined with domain name. As you invoke the sendmail with sudo, it uses the root user name to make the envelope return address. To change this behavior use the -f switch with sendmail:

   -fname Sets the name of the ``from'' person (i.e., the envelope  sender
          of the mail).  This address may also be used in the From: header
          if that header is missing during initial submission.  The  enve‐
          lope sender address is used as the recipient for delivery status
          notifications and may also appear in a Return-Path: header.   -f
          should only be used by ``trusted'' users (normally root, daemon,
          and network) or if the person you are trying to  become  is  the
          same  as  the  person  you are.  Otherwise, an X-Authentication-
          Warning header will be added to the message.
Share:
7,019

Related videos on Youtube

its_me
Author by

its_me

Updated on September 18, 2022

Comments

  • its_me
    its_me almost 2 years

    First, here are the entries I added/modified in /etc/postfix/main.cf file:

    mydomain = domain.com
    myorigin = $mydomain
    relayhost = email-smtp.us-east-1.amazonaws.com:25
    smtp_sasl_auth_enable = yes
    smtp_sasl_security_options = noanonymous
    smtp_sasl_password_maps = hash:/etc/postfix/sasl/amazon-ses
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_use_tls = yes
    smtp_tls_security_level = encrypt
    smtp_tls_note_starttls_offer = yes
    header_checks = regexp:/etc/postfix/header_checks
    

    Now, if I send a test mail like so...

    $ sudo sendmail [email protected]
    To: [email protected]
    From: [email protected]
    Subject: Test email!
    This is just a test email.
    .
    

    and check the mail log (/var/log/mail.log), I see this:

    Feb 17 04:23:16 hostname postfix/pickup[6226]: B3DD4137ED: uid=0 from=<root>
    Feb 17 04:23:16 hostname postfix/cleanup[6230]: B3DD4137ED: replace: header From: [email protected] from local; from=<[email protected]> to=<[email protected]>: From: "WebsiteName Alerts (no reply)" <[email protected]>
    Feb 17 04:23:16 hostname postfix/cleanup[6230]: B3DD4137ED: message-id=<[email protected]>
    Feb 17 04:23:16 hostname postfix/qmgr[6144]: B3DD4137ED: from=<[email protected]>, size=353, nrcpt=1 (queue active)
    Feb 17 04:23:18 hostname postfix/smtp[6232]: B3DD4137ED: to=<[email protected]>, relay=email-smtp.us-east-1.amazonaws.com[107.22.250.234]:25, delay=25, delays=24/0.03/0.93/0.58, dsn=2.0.0, status=sent (250 Ok 0000013ce6644ae6-69927d25-c4e1-4f25-8ad4-b85b59318e84-000000)
    Feb 17 04:23:18 hostname postfix/qmgr[6144]: B3DD4137ED: removed
    

    As you can see, the log shows both [email protected] and [email protected] as from even though I specifically stated [email protected] in the sendmail command.

    That too, despite modifying my /etc/aliases file like so:

    # /etc/aliases
    mailer-daemon: [email protected]
    postmaster: [email protected]
    nobody: [email protected]
    hostmaster: [email protected]
    usenet: [email protected]
    news: [email protected]
    webmaster: [email protected]
    www: [email protected]
    ftp: [email protected]
    abuse: [email protected]
    noc: [email protected]
    security: [email protected]
    root: [email protected]
    

    So, the question is, how do I make [email protected] the default email address-out for the system? Put it the other way, how do I change the email address of root user from [email protected] to [email protected]?

    In case this matters, my system's running Debian 7 (Wheezy) 64-bit.

  • its_me
    its_me over 11 years
    Maybe you didn't understand my question. When I send the mail, and the email is received at the other end, I do see that the email is sent by [email protected] itself. The thing is, the mail.log shows that the [email protected] for from is internally replaced with [email protected] before the email is sent. Or does it mean that the root user passes on the email from [email protected] locally to [email protected] for the latter to send it? Am I clear?
  • Serge
    Serge over 11 years
    I am sorry, not really. You typed in the From: header already containing [email protected] address at submission. The From: header and the envelope from address is not the same thing. Please check the Return-Path: header in the headers of the received e-mail. This address will be used to return any Delivery Status Reports when delivery fails, not the address in the 'From:' header.