php mail() and Google apps or ...???
I'm still learning but is there someway I can set up google apps to be able to work with the php mail() function or do I need to install something like postfix?
so that it relays it to Google App's for delivery.
I personally use postfix with Mail pear module as a fallback.
Thanks for your guide! I haven't tried yet but I should be setting up my mail this week so will definitely let you know how it goes!
I went through your steps and worked well for me, just a couple of minor points:
should now be
Also (for other n00bs who also tend to copy and paste code) "sudo chown http /etc/msmtprc" should be "sudo chown www-data /etc/msmtprc" if you've done the default Linode install of Apache.
Thanks though, I've set it up now and works well (except for
a problem @chrisg:
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: