chrisg wrote:
Thanks so much for the msmtp guide! Worked perfectly. Just one question though. Is there a way to change the email address it is coming from? Or is this all handled on the gmail side? No matter what address I put in for the from line it comes from my gmail account thats authenticated. This would be fine except I have multiple domains and do not want the mail coming from x.com when y.com is the website thats being used?!? Any help is greatly appreciated.
Yes, you should be able to do that, but it's a little extra work, since in my experience, the authenticated GMail account has to have been set up with the desired address(es) as an valid alternate address (which is thus verified as belonging to the same person). Otherwise it'll override the From header with the authenticated account. Essentially you're limited to controlling the From: field via the SMTP gateway to the same set of values you can use through the web interface.
So first sign onto the primary GMail account you are authenticating against. Then set up your desired addresses to use as alternate From values in the Settings/Accounts tab (in the "Send Mail As" section). Follow confirmation instructions as usual, which requires being able to receive mail to those accounts, so if you're sending on behalf of someone else you can enlist their help in forwarding over the confirmation message. Then you should be set.
You can't stop Gmail from placing your authenticated address in the Sender: field (which is reasonable, IMO) so if a receiving MUA erroneously decides to show that instead of the From: header you're stuck, but that would be non-compliant behavior on the part of the MUA. Again, no different from choosing a different From: address when sending a message from the web interface.
Note that any from value you give directly to msmtp is just going to get used for the envelope (the SMTP transaction), which aside from potentially showing up in a Received: header is not going to do much for how the mail is seen by people receiving it. You'll want to make sure that your desired address is placed in the From: header in the contents of the message being sent.
For example, in the referenced guide, when doing the test message include the line "From: <youremail@yourdomain>" above the Subject: line and see if that works. Then just arrange for whatever in your application stack composes the contents of the message to include the proper From header.
-- David