When using Gmail for SMTP, can you set a different from address?
gmail doesn't allow you to use random From addresses. You have to add and validate the address you'd like to use in the gmail settings:
Settings -> Accounts -> Send mail as -> Add another email address you own
changing from address on send_mail
I think this answers it. Gmail won't allow me to forge a from address, therefore the from address will always be admin@mywebsite.com
to send email with different 'from' email address using gmail smtp server in django
change sender address when sending mail through gmail in c#
Gmail doesn't allow you to change the FROM to something different than your gmail account.
It doesn't matter what you use, they over-write it, before they relay it on. This prevent spamming/spoofing.
How to use any email address in the FROM field while sending email through Gmail SMTP?
Having run your code snippet I get:
Return-Path: <my user>
Received: from Psi ([80.92.234.64])
by mx.google.com with ESMTPS id f1sm20531634wiy.2.2012.10.08.10.07.49
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 08 Oct 2012 10:07:49 -0700 (PDT)
Message-ID: <50730865.2152b40a.13ea.28ec@mx.google.com>
Sender: Roman R. <my user>
MIME-Version: 1.0
From: any email
To: my email
Date: Mon, 08 Oct 2012 10:07:49 -0700 (PDT)
Subject: Subject
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Body
Sender
is the email address used to authenticate with Google Mail. From
is the "from" provided in code. The receiving application might be confusing the two, and the rest looks just as expected. Some mail clients present the From+Sender (when they are different) as "sent by Sender on behalf of From".
You might be concerned with the fact that Google Mail still reveal the account from which the email is sent, through Sender
field, but this is how it works. You do send from this account.
And, another possible reason is the From
mail address itself. If you added it to your Google Mail account as one of your own addresses (and confirmed via test email with a link), then Google Mail will allow putting it onto From
field. Otherwise it might drop it and replace it with the Sender
.
Rails and Gmail SMTP, how to use a custom from address
I believe it's just something Gmail does when mail is sent through its SMTP, as it was mentioned that they do this on a tutorial about using their SMTP to send mail.
Sending email from secondary address using gmail SMTP
Looks like what I had to do was just wait...
Now it works fine without changing any code.
Related Topics
"Connection for Controluser as Defined in Your Configuration Failed" with PHPmyadmin in Xampp
Use a Variable to Define a PHP Function
Preg_Replace: Add Number After Backreference
Access Query String Values from Laravel
Is There Way to Keep Delimiter While Using PHP Explode or Other Similar Functions
Woocommerce: Assigning an Endpoint to a Custom Template in My Account Pages
Transpose 2D Array, Join Second Level with Commas, and Join First Level with Pipes
Google Gcm Server Returns Unauthorized Error 401
MySQL - Couldn't Connect Unknown Database 'Databasename' Error
How to Generate Random 64-Bit Value as Decimal String in PHP
Woocommerce - Hide Other Shipping Methods When Free Shipping Is Available
Smtp Server Response: 530 5.7.0 Must Issue a Starttls Command First
Import File Size Limit in PHPmyadmin
PHP Function with Unlimited Number of Parameters
Crop Whitespace from Image in PHP