# PHP, mail(), ssmtp, Gmail: how to get correct From address?

## Tatsh

I have figured out that if I enable FromLineOverride I no longer see 'added by portage for nginx' as the From name but I still see my Gmail user name instead of the one that is set with PHP. And if I use ssmtp and type From: somename@somename.com it still won't use that either, it always uses my email address in ssmtp.conf.

/etc/ssmtp/ssmtp.conf:

```
root=myname@gmail.com

AuthUser=myname@gmail.com

AuthPass=[]

mailhub=smtp.gmail.com:465

#rewriteDomain=

# hostname=_HOSTNAME_

# Set this to never rewrite the "From:" line (unless not given) and to

# use that address in the "from line" of the envelope.

FromLineOverride=YES

UseTLS=YES
```

Has anyone figured out how to get this to work or is it not possible (Gmail limitation)?

----------

## cach0rr0

"envelope" != header

envelope == what you send as an argument to the MAIL command, RCPT command, or anything in between. 

in order to do esmtp auth, the envelope return-path cannot be forged 

The "From" field that is displayed when viewing an email on a mail client is generally crafted by whichever "originator address" field you have present in the header, typically the From header or the Reply-To header. This, is indeed, something that can be forged, and while I don't have any specifics on the problem you're encountering (largely, because i dont know if gmail is simply seeing that no originator address header is present, and deciding to tack on the envelope return-path as originator address), maybe this explanation will help you understand what you are seeing. In simpler terms, your MAIL command, and AUTH command, should both be using a gmail address, while what is displayed as the sender should be derived from e.g. the "From" header

----------

