Google apps / php contact form ?

For my e-mail setup I am using Google apps and have msmtp-mta installed on my ubuntu 10.04 server.

On my site there is a php contact form that visitors can use for inquires.

My issue is that when someone sends me a message from the contact form the "From" field of the e-mail shows my default Google apps e-mail address instead of the visitors e-mail address.

Complicating matters is that I would like to host a few different domains on the server all of which would have contact forms on their sites.

Has anyone else run into this issue? I'm in need of some suggestions. :)

12 Replies

Google is going to set the email "From" based on how you authenticate to your Google Apps account combined with which sender addresses are authorized in that account. You should be able to do what you want as long as you do the initial setup in your Apps account to permit it to send email on behalf of the addresses you wish to use. (Or directly use the Apps account you wish to appear to be sending the messages)

If you're doing this on behalf of customers, having them acknowledge your ability to send mail on their behalf (when you set your Apps account up for it) could be part of your standard setup.

See also http://www.linode.com/forums/viewtopic. … 1325#31325">http://www.linode.com/forums/viewtopic.php?p=31325#31325

-- David

Thanks for the info! - I understand how to change the default e-mail account address now. But I'm still working on a solution as to how to get the correct From: address in the e-mails I receive when a random visitor uses the websites simple php mail() contact form. So far the only solution I can find is pointing to not using Google apps…

Just put the address you want into the From: header in the message you're formatting. The value has to be one of the authorized email addresses on the Google Apps account you use (or else it will replace it with the Google Apps address), but otherwise should work fine.

You'll need to make your PHP code appropriately decide which address to use based on who is completing the form, which is something that will be specific to your application.

– David

It would be pretty difficult to get ramdom users of your contact form to have themselves authorized by Google Apps. Why would anyone go through the hassle just to fill out a contact form? More importantly, why would random users of your contact form want to give you a right to pretend to be them?

If only a few people are going to read those contact-form emails (as is the case of most contact forms), you might as well save the hassle by including the user's e-mail address in the body of the message. Google will probably linkify it, so you can click on it and write your reply. Alternatively, you could set a Reply-To: header. That way, the e-mail will seem to come from a single authorized address, but when you click Reply it'll go to the person who filled out the contact form. Not sure if Google Apps allows custom Reply-To: headers, though.

As you said if it is not an authorized address Google apps will replace it with an authorized one it has listed in the account. In my case, my address.

So random visitor inputs into the contact form:

Name: John Doe

e-mail: JohnDoe@CrazyRandomDomain.com

Message: I had a question about blah blah…

The e-mail I receive looks like this:

From: John Doe <MyGoogleAppsEmail@MyDomain.com>

Message: I had a question about blah blah…

All I'm looking to do is just keep JohnDoe@CrazyRandomDomain.com in the From: field when I get the e-mail from the contact form and not have it replaced with my authorized email address. Maybe this can be done with Google apps premier, but as far as I can tell it cannot be done with standard.

Oh well. I was trying to avoid this, but I suppose I'll have to install some kind of "real" mail server…

@hybinet:

Alternatively, you could set a Reply-To: header. That way, the e-mail will seem to come from a single authorized address, but when you click Reply it'll go to the person who filled out the contact form. Not sure if Google Apps allows custom Reply-To: headers, though.

Google does allow for custom Reply-To: headers and I did try it out. I guess it is just a personal preference, but I just wasn't a fan.

@eekeek:

All I'm looking to do is just keep JohnDoe@CrazyRandomDomain.com in the From: field when I get the e-mail from the contact form and not have it replaced with my authorized email address. Maybe this can be done with Google apps premier, but as far as I can tell it cannot be done with standard.
Sorry, I misunderstood. I thought you were looking to have a specific per-domain email account (like a standard "info" or whatever) that would send messages on behalf of the form.

It's practical (IMO) to do this for a single address per client/customer/business domain, but clearly not to arbitrarily generate messages with any From address. No, I don't think trying to route through a Google Apps login (any level) is suitable for that.

– David

@eekeek:

Oh well. I was trying to avoid this, but I suppose I'll have to install some kind of "real" mail server…

Use exim and set it to only allow mail from localhost. It's very simple to setup for exactly this scenario.

@glg:

Use exim and set it to only allow mail from localhost. It's very simple to setup for exactly this scenario.

Awesome. I'll give it a look over in the library. Can exim be setup to deal with multiple domains?

Would this cause any issues with msmpt?

I know I'm going to run into this same problem, but can't you set the following headers:

From: "customer@hotmail.com" <noreply@yourdomain.com>
Reply-To: customer@hotmail.com</noreply@yourdomain.com>

This way shows better what is actually going on but will make for a confusing inbox:

From: "Company Contact Form" <noreply@yourdomain.com>
Reply-To: customer@hotmail.com</noreply@yourdomain.com>

Will this work with Google Apps (assuming the noreply account is setup at GA)? The first example probably smells like spam, so you might need to create a filter at GA to prevent it from being flagged as such.

EDIT: I guess a mixture of them both and something like the following would be best?

From: "Customer Enquiry: customer@hotmail.com" <noreply@yourdomain.com>
Reply-To: customer@hotmail.com</noreply@yourdomain.com>

EDIT2:

Just tested and all the above methods work fine. I can't say how they compare when it comes to spam detection since I have everything set from the address I used to not be marked as spam.

@KyleMac:

This way shows better what is actually going on but will make for a confusing inbox:

From: "Company Contact Form" <noreply@yourdomain.com>
Reply-To: customer@hotmail.com</noreply@yourdomain.com>

Like you said it does make for a confusing inbox. That’s why I wasn’t a big fan of that solution. I haven’t had much time to work on the problem or figure out exim. I’m still not sure if running exim and msmpt at the same time will cause any problems. Also, everything I have looked at for exim dealing with multiple virtual hosts has caused my head to spin so I’m still trying to find a good tutorial on that. Let me know if you come up with anything!

The first set of headers I posted are the solution you want.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct