from address come with server extension in mail - php

from address come with server extension, errror info#gmail.com via ecbiz132.hostername.com . how to solve this
$subject = "confirmation";
$from = "info#gmail.com";
$to = $email;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To:<'.$to.'>' . "\r\n";
$headers .= 'From: <'.$from.'>' . "\r\n";
$senad_replay = mail($to, $subject, $content, $headers, $from);
// errror info#gmail.com via ecbiz132.hostername.com . how to solve this

Yes, you can get rid the "via" part. Here's the details:
1) SPF and DKIM
Firstly, you would need to set an SPF record for the domain you are sending emails from and enable DKIM as well. These are primarily for identifying your messages against spam.
2) "From: anything#yourdomain.com"
Secondly, make sure you are setting the “From: ” header to be an email address on the domain you are sending messages from. Don’t pretend to be someone else. Use “From: someone#abc.com” if you are sending the messages from abc.com, rather than anything else, such as blah#def.com, or yours#gmail.com, or whatever. If you want the recipient to reply to your Gmail email instead of your domain email, use the “Reply-To: ” header. “From: ” must always be the domain email that you are sending the email from.
3) "Return-Path: return#yourdomain.com"
Thirdly and most importantly, set the “Return-Path: ” header to be the same domain as that of the “From: ” header. Use the 5th parameter of the mail() function for this:
mail('recipient#example.com', 'Subject', "Message Body", $headers, '-freturn#yourdomain.com')
So the Return-Path of this message would be “return#yourdomain.com” (the email address immediately following the -f switch). The $headers parameter should contain all the necessary message headers. Make sure “From: ” is something#yourdomain.com.
After these steps and measures, Gmail should now completely trust your messages from yourdomain.com. The ‘via‘ field of your messages should be gone and the ‘mailed-by‘ field as well as the ‘signed-by‘ field should be correctly showing up as yourdomain.com.
Hope it helps!

Related

How to prevent HTML email not ending up in junk folder in hotmail?

I have been sending an email to the user who signs up on my website. The email is correctly being sent to inbox folder in other services like gmail, yahoo but in case of hotmail sometimes it ends up in junk folder and sometimes it goes to inbox.
Below is my email code snippet from my registration code:
$user->save();
$activationUrl = Yii::app()->request->getBaseUrl(true) . '/site/activateaccount?activation_key=' . $activationKey;
$body = $this->renderPartial('accounts/registration_email', array('activationUrl' => $activationUrl), true);
$subject = 'Please complete your signup';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Website Name<admin#mydomain.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.='Reply-To: admin#mydomain.com' . "\r\n";
$headers.='Return-Path: admin#mydomain.com\r\n';
if (mail($user->email, $subject, $body, $headers)) {
$this->redirect('registersuccess');
}
Please note that the email I send is HTML email and in above code I have replaced website domain with mydomain.com for privacy and website actual name with Website Name.
I have tried changing email subject line, MIME-version and content type.
Tried so many solutions already posted on SO here but no one makes it always go to inbox rather than junk.
My clinet has email account on hotmail so he wants that email to end up in inbox no matter what. Can something be done as sure shot solution? Does installing SSL on site domain solves this issue? Any other solution?

PHP mail() not sending

I have a WebFaction server and the following code:
$to = "outreach#bmun.org";
$reply_to = "From: " . $_POST['email'];
$name = $_POST['name'];
$subject = "Outreach Request Session for " . $_POST['school'] . " on " . $_POST['date'];
$em = $_POST['message'] . "\n-" . $name;
$sentmail = mail($to, $subject, $em, $reply_to);
$sentmail returns true, but the email is not sending for some reason.
$sentmail returns true, but the email is not sending for some reason.
The mail function in PHP simply sends the mail via an MTA (mail transfer agent) on the server. A true can just mean the local MTA accepted it. But that is not all you need.
First, does your hosting provider actually allow outgoing mail? Or are messages sent to a virtual “black hole?”
Now, let’s assume that your local MTA—most likely sendmail—works, and the mail jumped off of the server & made it into the real world. Okay, great!
But not so fast…
The thing is just because you send a mail, it doesn’t mean that the receiving end thinks the mail is valid. And chances are the receiving end has decided a random e-mail sent off of a random server is simply SPAM.
I have posted a more detailed answer here, but when it comes to SPAM it basically boils down to this: Do you have an SPF (Sender Policy Framework) record setup for your domain? Do you also have a PTR (reverse DNS) record set for that domain?
If you do not have an SPF or PTR record, the chance of your message simply being flagged as SPAM is quite high.
If you are serious about sending mails off of your server, you need to at least get your SPF record & PTR record set.
You don't have any headers in your email.
Although they don't seem to be required, your emails will be blocked by spamcheckers a whole lot sooner.
This is an example:
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
?>

How to format an email that Hotmail / Outlook is happy with?

$body = 'This is a test';
$subject = 'Confirmation';
$headers = 'From: Testing Site' . "\r\n";
$headers .= 'Reply-To: admin#myserver.com' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion(). "\r\n";
$headers .= 'Delivery-Date: ' . date("r") . "\r\n";
//$headers .= 'Message-Id: <20140316055950.DA8ED58A13CE#myserver.com>' . "\r\n";
mail("example#hotmail.com", $subject, $body, $headers, "-f admin#myserver.com");
mail("example#gmail.com", $subject, $body, $headers, "-f admin#myserver.com");
Emails send fine to Gmail but are always rejected by Hotmail with this error:
host mx1.hotmail.com[65.55.33.119] said: 550 5.7.0 (COL0-MC5-F28)
Message could not be delivered. Please ensure the message is RFC 5322
compliant. (in reply to end of DATA command).
Message ID header is generated automatically by the server but it doesn't help to supply one manually either.
Why isn't Hotmail happy?
Mail server has SPF record, reverse DNS, is not blacklisted and passes all checks at mxtoolbox.com.
The From header is invalid. It must have the following syntax:
From: "name" <email-address>
In your case:
From: "Testing Site" <admin#myserver.com>
The same goes for your Reply-To header:
Reply-To: "Testing Site" <admin#myserver.com>
Which you can omit if it's the same as the From header (like in your case).
PS: RFC 2822 doesn't state that the display-name in an address should be quoted. In other words: the following 3 headers should all work:
From: "Testing Site" <admin#myserver.com>
From: 'Testing Site' <admin#myserver.com>
From: Testing Site <admin#myserver.com>
If you're using WordPress, you can look up plugin for Hotmail/Outlook friendly emailing capability.
However if it is a standalone script you might wanna look into Microsoft's official answer to this query on the URL : http://answers.microsoft.com/en-us/outlook_com/forum/oemail-osend/why-are-the-emails-sent-to-microsoft-account/b64e3e4a-0d93-40c8-8e28-4be849012f9c
In-short Email-Server provider has to fill this form (once) : https://support.live.com/eform.aspx?productKey=edfsmsbl3&ct=eformts&wa=wsignin1.0&scrx=1
In order to get their emails accepted by Hotmail/Outlook.
Using the PHPMailer library to send mail instead of the mail() function has finally sorted this problem and is the working solution for me. Answer by Jasper N. Brouwer probably more correctly answers the question though I've not had a chance to try it.
1 ) Go to SPF record wizard
2) create a new SPF record for your DNS domain
3) Add that DNS record to your domain's DNS
4) if you fail somewhere in the process, read the detailed SPF record specification
After you complete this process HOTMAIL will be happy with your email.

PHP mail doesn't require a password?

I got my mail script to work properly but I don't understand why PHP mail doesn't require me to enter the password for the from address.
Isn't it this dangerous? Couldn't someone use someone else's email to send inappropriate messages?
The mail script I used:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
mail($to, $subject, $message, $headers);
In other words: lets say if the I put your email address as the value of $from, that will send emails under your address.
Couldn't someone use someone else's email to send inappropriate messages?
Yes. If you check your spam filter, you'll see lots and lots of these - messages that appear to be from major companies, government institutions, etc.
The way to prevent this is not a password, but proper SPF and DKIM records in your domain name's DNS settings.

Extra characters in PHP email "from" field

I'm trying to send email from PHP, and although it's working, I'm noticing that I'm getting a lot of extra stuff in the "from" part of the email. The extra stuff, I'm assuming, is
information from my server?
For example, if $from = "myname", instead of "myname" only coming through in the email from field as is, I get something like:
myname#p3nlhg.phx3.secureserver.net
Here is my PHP I'm playing with, the important part being my $from var:
$from = "myname";
mail($to,$formSubj,$formMssg,$from);
Honestly that's all I have, nothing more or less (as far as the $from is concerned). How can I clean this up or make it so that only the plain value of $from, which is in this case "myname", comes out?
The 4th parameter of the mail function doesn't work this way. It expect header information. To achieve what you want to do use:
$header = "From: myname <no-reply#test.com> \r\n";
mail($to,$formSubj,$formMssg,$header);
You shouldn't use a lonely myname either. You need a valid email addess string: myname <no-reply#test.com> or no-reply#test.com. If you just put myname, PHP will try to interpret it as an email address. That's why you're getting myname#p3nlhg.phx3.secureserver.net. p3nlhg.phx3.secureserver.net must be the hostname of your server.
A nice thing about the header parameter is that you can use it to specify other less common fields. e.g.:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
Notice that you need to place a carriage-return/line-feed (\r\n) at the end of each header attribute. A simple line feed will not work.
According to the mail documentation, you're using $from as the $additional_headers argument.
Instead, change $from to an appropriate header. For example,
$from = "myname";
$headers = "From: $from <user#example.com>";
mail($to, $formSubj, $formMssg, $headers);
According to the documentation for additional_headers,
When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.
It's coming from the mail server that you have installed in your server, try to switch to another one, like postfix, courier or someting else.

Categories