Removing 'gmail.com' from the 'from' when using gmail smtp and phpmailer - email

I am using PhpMailer to send emails via gmail smtp. And while $mail->setFrom('jack.schmitt#domain.com','Jack Schmitt'); does insert 'Jack Schmitt' as the name of the sender, it is still including my smtp username. So the recipient will see something like this: Jack Schmitt<smtp_user#gmail.com> in the From: line
Is there a way to have it say Jack Schmitt<jack.schmitt#domain.com> in stead?

You can't send using arbitrary from addresses, because that would usually be forgery. You can only send from your account address or predefined (in gmail settings) aliases. This is a gmail feature covered in their docs.

Related

hide the fact that an email is sent from gmail's web interface

Does anyone know if you can hide or modify some of the header fields from the sent email via the Gmail web interface?
such as:
X-Gmail-Original-Message-ID: xxxxxxxxxxxx#mail.gmail.com
Message-ID: xxxxxxxxxxxxx#mail.gmail.com
My idea would be to completely fake (hide the fact) that the said email was sent from the Gmail web interface. The goal of that would be simple - use Gmail even if the company you work for, does not allow it.
Perhaps there is a Gmail extension for that?
AFAIK, you can only change the from email when sending email from Gmail. Take a look at Send emails from a different address or alias.
Also, there are techniques to really find out where an email came from; forging email headers and/or spoofing emails is something that spammers do and will get your IP address blacklisted by your ISP.
You can also check How can I find out where an email really came from?. The headers can also be put in SpamCop and let them do the trace work with an option of sending a SPAM notice to the responsible sysadmin.

Removing 'on behalf of' when sending mail using MailGun

I'm trying to figure out how to send mails using the MailGun Golang API without having it sent 'on behalf of'.
This is how the From address currently looks (where foo.com is the sender's email domain and bar.com is my domain):
john=foo.com#mail.bar.com on behalf of John Smith <john#foo.com>
What do I need to do so that it looks like this instead:
John Smith <john#foo.com>
I've set up SPF and DKIM according to the MailGun instructions and everything passes as being correct. I've also used SetDKIM(true) when I'm sending out the mail. Is there some setting I'm missing or additional validation I need to do?
You need to set the sender property in the email header to the from address as well most likely.
I had this same problem using NodeMailer for a node.js project. Gmail and Thunderbird would show the from address fine but Outlook would show the from address as
emailname=example.com#mail.example.com on behalf of emailname#example.com
When I looked into the full email message header I saw that the sender: in the header was emailname=example.com#mail.example.com and the from: was emailname#example.com
we looked into the spf and dkim records at first thinking it was an issue there but they were fine and in the email header it even said spf and dkim both were passing so then i noticed the sender header was different than the from and Outlook pays attention to that where gmail and thunderbird don't care as much.
Try setting the sender header to the from value.
Here is a sample of part of one of the wrong email headers edited to match example above
Received-SPF: pass (google.com....
Authentication-Results: mx.google.com;
dkim=pass header.i=#mail.example.com;
spf=pass (google.com.....
Sender: emailname=example.com#mail.example.com
From: Persons Name <emailname#example.com>
make Sender equal to Sender: Persons Name <emailname#example.com>
To add to Dhodgin's answer:
The on behalf of message comes up if you're using a subdomain in MailGun such as mail.bar.com and the from email address is using a different domain such as john#foo.com
To fix this issue add a custom MIME header "sender" and set it to be the same as the from email address.
To add a custom header using the MailGun api make sure to add a h: prefix such as:
request.AddParameter("h:sender", "John Smith <john#foo.com> ");
Have you added an mg sub domain?
If you have added a sub-domain such as #mg.domain.com then make sure you send your emails from name#mg.domain.com
I had the same problem, as I didn't realize that I wanted to have the sender address name#domain.com but I had added - as recommended - a subdomain to mailgun: mg.domain.com.
So when I tried to send an email from name#domain.com I got "on behalf of" / "sent by" but as soon as I've used the subdomain name#mg.domain.com - the "on behalf" message is gone... stupid me...
Are you trying to send from a different domain than the one you setup SPF/DKIM on?
You can only send white-labelled emails from the domain you're authorized with Mailgun.
For those using SMTP in mailgun subdomain. Set the "From" and "Sender" parameter. eg
message["From"] = 'John Smith <john#foo.com>'
message["Sender"] = 'john#foo.com'

Receive (not forward) e-mail using Mailgun

I want to use Mailgun to send/receive messages programatically via API.
BUT I need to have also some mailboxes available using Thunderbird or other mail client.
For example I want to have user mailboxes at:
support#
sales#
admin#
And all other e-mails will be for API send/receive.
I can not forward my mail to GMail because I need to reply from the same address (sales#mydomain.com).
Please help.
There is a limitation to using the routing feature and that is that if you delegate a domain to be used by Mailgun you cannot use it with an email client.
That means that, for example, if you want to route emails to user#domain.com and then still use that email address with your favourite email client (be it Thunderbird, Outlook or Gmail) you can't do it. That is because of the way you've configured your MX records (email records in your DNS).
When you use Mailgun's routing functionality you delegate MX records to mailgun, which receives your emails, parses them and routes them according to your preferences.
So how do we solve your problem?
What you can do instead is set up your MX record on a subdomain.
Using subdomain.mydomain.com and pointing its MX records to mailgun will allow you to receive and parse emails through Mailgun.
This way you can have:
admin#subdomain.mydomain.com
sales#subdomain.mydomain.com
etc
will be handled by mailgun
while
admin#mydomain.com
sales#mydomain.com
will be handled normally with your email client.
Please do not hesitate in asking more details!
You need to configure your MX record settings for your subdomains in your DNS control panel.

Postfix - Set the reply-to address based on the sent-to address when sending email

I have multiple domains which I receive e-mail for and have set up my mailserver to deliver it all to a single mailbox for convenience, example below:
comment#myblog.com
contact#mybusiness.com
admin#mywebsite.com
They all come to me at my single mailbox:
ian#me.com
When I reply to these e-mails the reply-to address will be:
ian#me.com
I would like to automatically have postfix change that reply-to address, based on the address that the e-mail was originally sent to, so for example:
Email is sent to me at: comment#myblog.com
I reply from: ian#me.com
I want the reply-to to be: comment#myblog.com
Is there a way to automate this with postfix?
Thanks in advance.
It is doable in postfix anyway. But it requires some programming to parse the mail to determine the recipient email address and add Reply-To header from that value. You need to use an external content filter or a Milter application. But I dont think it is a cleaner way.
I would rather say that setting Reply-To header should be done by the MUA eg. (Thunderbird, Outlook etc ) instead of Postfix MTA. For eg. in Thunderbird, If you receive all your emails for
comment#myblog.com
contact#mybusiness.com
admin#mywebsite.com
at ian#me.com, then you can add identities for all the email addresses above( You can set your Name, Email address, Reply-To address etc). So when you reply to an email sent to comment#myblog.com, then the Reply-To address will be set to comment#myblog.com. For Thunderbird, you have to add identities by clicking Edit -> Account Settings -> Manage Identities. More info here. All MUAs should have this option of managing identities.
Hope that helps.

sendmail disabled

My host has Sendmail() disabled. I'm basically looking for a way to bypass this. I want visitors to be able to send me (gmail account) an email where they first fill in their e-mail address, so they become the sender. It's for support questions and remarks.
If there is no way to bypass this, is there and alternative, perhaps using mailchimp..?
You can always use an alternative public send mail servers available. You can use one of them. Here is one Public Send Mail server list
use phpmailer library. you can send email via connecting smtp (works with gmail too.) 1st configure one of your accounts with phpmailer. when the user fills in their email set the sender as user's email.
even though you are actually sending the email through your account to receiver of the email will show as sent by user's email address.
http://phpmailer.worxware.com/