My setup: I'm running a Magento website on an Amazon Linux server (which seems to basically be CentOS) with an Apache webserver. I also use Google Apps for managing mydomain.com's mail.
I was able to successfully set up the MX, SPF and DKIM records for the server and got them working, so that I receive a "Pass" for both SPF and DKIM when I send emails. However, I've run into a strange problem I can't seem to get past --- part of the header for the emails I send seems to always say:
Received: (from apache@localhost) by mydomain.com
I've searched high and low for a way to change this to use "email@example.com" instead, but I just can't seem to figure it out.
Among things I've tried:
- Changing the php.ini to say: /usr/sbin/sendmail -t -i -f firstname.lastname@example.org
- Adding to mydomain.conf's virtualhost the line: ServerAdmin email@example.com
- Setting the Return-Path to "Yes" in the Magento backend (System -> Configuration -> Advanced -> System -> Mail Sending Settings.
If it helps, the contents of my /etc/hosts file are as follows:
127.0.0.1 www.mydomain.com 127.0.0.1 mydomain.com 127.0.0.1 localhost localhost.localdomain
For the last line of the hosts file, I also tried the variation...
127.0.0.1 localhost.localdomain mydomain.com
...but it still didn't work.
I thought it might also help if I added the headers of the email, in case that might give some clues to what might be going on (I've changed a lot of values to keep it generalized).
Delivered-To: firstname.lastname@example.org Received: by 18.104.22.168 with SMTP id abcdefg123456790; Fri, 3 Apr 2015 08:35:04 -0700 (PDT) X-Received: by 456.456.456.456 with SMTP id asdfqwerhjkl234hjkl.789.78909876789; Fri, 03 Apr 2015 08:35:03 -0700 (PDT) Return-Path: <email@example.com> Received: from mydomain.com (ec2-11-11-111-11.amazonaws.com. [66.66.777.77]) by mx.google.com with ESMTPS id asdkfjhkjdfha839383.105.2015.04.03.08.35.02 for <firstname.lastname@example.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Apr 2015 08:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of email@example.com designates 66.66.777.77 as permitted sender) client-ip=66.66.777.77; Authentication-Results: mx.google.com; spf=pass (google.com: domain of firstname.lastname@example.org designates 66.66.777.77 as permitted sender) email@example.com; dkim=pass firstname.lastname@example.org Received: from mydomain.com (www.mydomain.com [127.0.0.1]) by mydomain.com (8.14.4/8.14.4) with ESMTP id t33FZ29p004251 for <email@example.com>; Fri, 3 Apr 2015 15:35:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mydomain.com; s=default; t=fjIFDJF9049; bh=fjO4J4f09j409JF04J909f4j904JF940F9/Y=; h=To:Subject:From:Date; b=F4J90FJ490j09j490FJ094J0j94f90j409j490Jf90j904JF09j490fj904jf094J f09J40F9J904fj049J099j49J049J0FJijffjdlfjldkDLFJKLdjflEJFOIJFOEIEO JF9JF049j409j0F094J09FJ049jf049j= Received: (from apache@localhost) <----------- THIS IS WHAT I'M TRYING TO CHANGE by mydomain.com (8.14.4/8.14.4/Submit) id fkdjfljlfsra39393; Fri, 3 Apr 2015 15:35:01 GMT Message-Id: <firstname.lastname@example.org> To: =?utf-8?B?Sm9lIEdhcmNpYQ==?= <email@example.com> Subject: =?utf-8?B?VGVzdCBOZXdzbGV0dGVyLCBwbGVhc2UgaWdub3Jl?= X-PHP-Originating-Script: 48:Sendmail.php From: "mydomain.com" <firstname.lastname@example.org> Date: Fri, 03 Apr 2015 15:35:01 +0000 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline MIME-Version: 1.0
Part of me isn't sure if this is normal, and I guess I'm not sure what might be causing the apache@localhost to appear, but if anyone has an idea it would be much appreciated, thank you!
Edit The MTA I'm using is Sendmail. Here are the configuration changes I've made to the sendmail.mc file to accommodate for my site.
MASQUERADE_AS(`mydomain.com')dnl FEATURE(masquerade_envelope)dnl FEATURE(masquerade_entire_domain)dnl INPUT_MAIL_FILTER(`opendkim', `S=inet:email@example.com') define(`confCW_FILE', `/etc/mail/local-host-names')dnl dnl define(`confDOMAIN_NAME', `mydomain.com')dnl
Edit I'm not sure if this question got marked as a duplicate again, so I thought I should emphasize the reasoning why it's not based on the referred question as to why it isn't. Switching to Postfix isn't a solution, so much as a workaround. I would hate to uproot all the setup I've done with Sendmail so far only to encounter other potential problems trying to get Postfix to work instead. I also already mentioned editing the sendmail command in php.ini, if you read the bullet points I mentioned above.
Edit I figured I might as well mention some of the other things I tried doing that didn't work. I added to my sendmail.mc the following lines:
FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
I then created a generics-domains file with the single line "mydomain.com" inside of it. Then, I created a genericstable file with the single line "apache firstname.lastname@example.org" inside of it. I ran make in the mail directory, recreated the cf file, and restarted sendmail, but no dice.
I tried editing the /etc/aliases file. I tried changing the line "apache: root" to say "apache:root,email@example.com", as well as just "apache:firstname.lastname@example.org", but that didn't do anything either.
I also tried adding to the /etc/mail/virtuserstable file the single line "apache@localhost email@example.com". That didn't do anything either.
I'm surprised at how frustrating it is to get this working properly. I'm so close to having it where I need it, but I honestly don't know where to being looking to get the "apache@localhost" line replaced.