about: How to Send Mail from Any Account, with Any Custom From: Address with Gmail

How to Send Mail from Any Account, with Any Custom From: Address with Gmail

With regard to sending mail "from" another account via my gmail account, I was wondering how gmail does this? For example if I have a work account at me@mycompany.com and I register it at Gmail and then start to send mail from gmail but set the from box to me@mycompany.com and not me@gmail.com, then does gmail forward this mail to the mycompany server or how does it accomplish this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't work for GMail and therefor have absolutely no clue as to what GMail specifically uses, I do know that you can easily send mail from any E-mail address with PHP's mail() function, which very likely could be the answer to your question.

I have attached some PHP code that sends E-mail from me@mycompany.com.
$to = "someone@somedomain.com";
$subject = "A Test Subject";
$message = "Hello! This is a test E-mail message.";
$headers = "From: me@mycompany.com";

Open in new window

The "From" address in an email is just an address stored in the header of the email message, among other information regarding the email, it's content, and where it came from.

When the is delivered, the from address specified in the email header is what an email program is supposed to show.

However, changing the From address in a header of an email is a common way to "spoof" an email address. For example, you could send an email to someone making it look like it was from Support@microsoft.com requesting personal information... and some people might just buy it.

For this reason, changing the "From" field to something other than the original sender of the email is very often flagged as "suspicious" by many mail programs. Hotmail immediately shows you warnings and doesn't immediately allow you to open the message. Other email programs might classify the message as junk, or even delete it immediately, all depending on how strict the email server or program is.

So long story short, you can change the from address by adding an appropriate tag to the email's header. But use it with care, because many email programs and servers don't play nice with it.
onyourmarkAuthor Commented:
Hi, I use gmail and they allow me to choose the from address. I can say it is from me@gmail.com or from me@mywork.com, but I was wondering whether they actually forward it thru mywork.com or what??
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

No, they don't. Gmail never contacts mywork.com because it doesn't have the proper authentication information to do it. GMail just changes the "from" tag in the header of the email address, like we explained above.
If you were to send an email using gmail, specify the from address as "me@mywork.com", and send it to someone, that person would indeed see it as "from me@mywork.com", but opening the email and examining the raw header more carefully would show that the email went through gmail servers, and that the true sender was actually me@gmail.com.

Think of that "From" box as actually meaning "Sent on behalf of"
onyourmarkAuthor Commented:
Hi, below are the instructions at GMAIL for setting up an additional address for the from box. I still cannot figure out if they send it thru the other account or not though. Also, where do I check the raw header more carefully to confirm?
Adding a custom 'From' address

Gmail's custom 'From:' feature lets you send messages with another address in place of your Gmail address, making it easier to manage multiple accounts from the Gmail interface.

To add a custom 'From:' address:

   1. Make sure you can sign in to the account you'd like to add. You'll need to access the account before Gmail will let you send from it.
   2. Please note: If you'd like to send from another Gmail username, be sure to sign up for the account first. Sign in to your Gmail account.
   3. Click Settings along the top of any page, and open the Accounts tab.
   4. Under Send mail as, click Add another email address.
   5. In the Name field, enter your full name.
   6. In the Email address field, enter the email address you'd like to send from.
   7. (Optional) When someone replies to a message you sent using a custom 'From:' address, the reply will be delivered to the 'From:' address rather than your Gmail address. If you'd like replies to be delivered to Gmail or a third account, you'll need to enter a 'reply-to' address. To do this, click Specify a different reply-to address and enter the email address you'd like.
   8. Click Next Step >> and then click Send Verification. Gmail will send a verification message to your other email address to confirm that you own it.
   9. Open your other account and either click the link in the message Gmail sent or enter the confirmation code in the Accounts section of your Gmail account settings.

To use a verified custom 'From:' address when composing a new message, pick your desired address from the drop-down menu in the 'From:' field. If you're replying or forwarding, click change next to the 'From:' field first. You can also choose to automatically use the address to which a message was sent.

To edit the name or reply-to address for an existing entry, click edit next to the address on your Accounts tab. To delete an address, just click delete.

Note: when you're sending with a different 'From:' address, your Gmail address will still be included in your email header's sender field, to help prevent your mail from being marked as spam. Most email clients don't display the sender field, though some versions of Microsoft Outlook may display "From yourusername@gmail.com on behalf of customaddress@mydomain.com."

For the third time, it's not being send through any other server other than gmail.

The instructions you are looking at, with the email validation, are there so that you can't just put *any* email address into the from address. You have to prove to gmail that you actually have access to that address. It is to stop you from abusing the service.

When you receive a message from Gmail, click the little down arrow, beside "reply" in the top-right corner of the message window. Click "Show Original" to see the original message, complete with header at the top.

Say you have a gmail account, me@gmail.com. You make a custom "From:" address as me@mycompany.com. Then you send an email to someotherguy@hotmail.com.

When someotherguy@hotmail.com checks his email, he'll see a new message that says it is from me@mycompany.com. However if he opens his message and looks at the header, he'll see this:

Received: by with HTTP; Fri, 15 Feb 2008 21:17:52 -0800 (PST)
Message-ID: <37fd93d10802152117q2a3699aaj43cd5f7b3a36557d@mail.gmail.com>
Date: Sat, 16 Feb 2008 00:17:52 -0500
From: "Test Account" <me@mycompany.com>
Sender: me@gmail.com
To: someotherguy@hotmail.com
Subject: blah blah
MIME-Version: 1.0
... etc

The "From" field contains the address you entered into Gmail as the "alternate" from address. But notice that "Sender" never changed, it stays your gmail address. Also notice that this never touched the mycompany.com servers. It was handled and delivered using Gmail only. The "from" address is just some text.

The mycompany.com server is never contacted. The "from" field, which is just TEXT in an email header, was simply changed to something else. Hotmail, or outlook, or eudora of whatever email program that receives the email, will usually display whoever was in the "From" field as the person who sent the email. Most email programs, if the "From" differs from the "Sender", will also display a warning that the email was sent on behalf of someone.

This is what gmail's instructions were describing when they said: "Note: when you're sending with a different 'From:' address, your Gmail address will still be included in your email header's sender field, to help prevent your mail from being marked as spam. Most email clients don't display the sender field, though some versions of Microsoft Outlook may display "From yourusername@gmail.com on behalf of customaddress@mydomain.com.""

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
onyourmarkAuthor Commented:
Now it is really clear
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Servers

From novice to tech pro — start learning today.