I want users on my website to use php mail() to send emails from my website domain. I would like users to get replies on their personal email address which will not be my domain email it might be gmail, hotmail or any other. When I do so, the email recipients get a phishing warning in gmail.
How can I set headers in php mail() so different sender and reply-to emails do not make gmail and other services tag the email as spam or phishing.
Your recipients are getting a pishing warning because your emails are not passing SPF checks. That simply means that the from domain you are using is not authorizing your server to send mail on its behalf.
Try using PHPmailer https://github.com/PHPMailer/PHPMailer
You can use it to set a separate from address as well as a specific reply to address
$mail->AddReplyTo('replyto#email.com', 'Reply to name');
$mail->SetFrom('mailbox#email.com', 'Mailbox name');
That being said. The SetFrom address is an address that must pass SPF and preferably DKIM checks to be NOT marked as SPAM or PISHED. This address is recognized as the BOUNCE address where all the bounced emails will be returned to. Not having a valid address may possibly disrupt future deliveries.
The AddReplyTo address will be loaded when the reply button is clicked by the recipient. Keep in mind that even though the message may pass SPF there are many SPAM filters that will potentially mark the message as spam.
The easiest way to get this working is to create an email address on your website (me#mysite.com) then get the website to automatically forward all mail to your gmail account. Then, use the website email address in the 'From' and 'Reply-To' address of your mail() routine.
Related
I am using PHPMailer for email sending, I am wondering how could I remove 'via page domain' in received email?
Example:
Thank you.
Remove "via" information from emails not sent through Gmail
Gmail checks whether the messages you send are authenticated.
If you send messages with a bulk mailing vendor or third party affiliates, prevent your emails from being blocked by Gmail.
Publish an SPF record that includes the IPs of the vendor or affiliates which send your messages.
Sign your messages with a DKIM signature that is associated with your domain.
Make sure the domain in the "From:" address matches the domain you're using to authenticate your emails.
More about it here:
https://support.google.com/mail/answer/1311182?hl=en#zippy=%2Ci-see-via-and-a-website-name-next-to-the-senders-name
I have an SMTP webservice that sends emails from various applications. I use phpMailler to make these submissions. I use a GMAIL account to perform SMTP sending. When my client receives this email and opens it in their inbox, the sending server e-mail appears, in this case GMAIL. Is there any way to replace this email with another?
With gmail, no. What you're asking for is usually considered forgery, and will be blocked by SPF record checks. Gmail does not allow you set arbitrary from addresses. You can preconfigure aliases within your gmail settings, but that doesn't let you add new address at send time and there are a limited number available.
You have some options though - ensure that the from address you're using does have appropriate SPF records to allow you to send from it, or live with the from address and set the reply-to address to point where you want replies to go - this is how contact forms are usually configured, along the lines of:
$mail->setFrom('from#example.com', 'First Last');
$mail->addAddress('whoto#example.com', 'John Doe');
$mail->addReplyTo($_POST['email'], $_POST['name']);
Alternatively, if your sender addresses are set by users, then you need credentials for those email accounts so that you can send through them directly, rather than forging it through gmail.
I am sending email using Gmail SMTP account, but I want show different sender email to the receiver. I am using below code to override the from email address.
Mail::send('emails_old.send_message', ['data' => $request->message], function ($message) use ($request, $toEmail, $cc, $bcc, $attacments)
{
$message->to($toEmail);
$message->subject($request->subject);
$message->from('no-reply#xyz', 'No reply');
$message->replyTo(auth()->user()->email, auth()->user()->name);
});
Above code working fine & also overrides sender name, but not email address.
can anybody tells what's wrong I am doing?
Thanks,
Kaleem
Gmail only permits you to use a From address that's in your Settings as a verified alias. You can't (and shouldn't) spoof an email address you don't control. If nothing else, it'll frequently be flagged as spam because of SPF records. – ceejayoz
If you want to use a different email address where the mail is send from try using a mail server, or try using a maildriver such as mailgun.
I only use Gmail SMTP for development, after that I switch over to my mail server.
I'd note that while other services may allow you to do this, it's still a horrible idea. SPF records will send a lot of email sent like this to spam. – ceejayoz
So if it's just for development or a school-project, you can use mailservices like mailgun or Gmail SMTP. Otherwise try to get a mail server to handle no-reply emails.
I've built a contact form in which a sites visitor enters a message, subject and his own email address. The email then is sent to a fixed gmail address.
I'd like the receiver of the mail to be able to just click on answering in order to respond. Therefore I set the senders email to that one entered by the sites visitor.
Problem is, gmail considers those mails as spam. I guess because the DNS of the senders address does not fit to the servers IP.
So I wonder if there is a strategy to achieve what I have described.
There are other email addresses you can add that will probably fix your problem. I suggest that you give your email From, Sender and Reply-To addresses:
From: visitor's email
Sender: your email
Reply-To: visitor's email
Reply-To is the address any reply will go to. Sender means that the email coming from you makes sense. From indicates that you are sending it on behalf of the visitor.
I use the mail() function to email customer completed forms to my easyspace account. However any forms that have a hotmail from email address specified are unreceived. They are not in my spam folder either. If i send an email direct from a hotmail account this doesn't happen. Any ideas why this would be happening?
Never ever use a from address that differs from the domain your site is running on. You can put into reply-to anything you want (including hotmail addresses) but from must contain a legit mail address.