PHP mail doesn't require a password? - php

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.

Related

How to hide server name when send email using php to gmail?

How to hide server name when send email using php to gmail?
I test my code on hotmail it's not show server name , But when i test send mail to gmail why gmail show server name. How to remove it's
http://image.ohozaa.com/i/b2b/Jqx7Zg.png
$headers = 'From: NUMBERONE<admin#numberone.com>' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
How can i do?
I think you will find that the hostname is still there in hotmail (view email header/source). Gmail just chooses to make it visible for anti-spam/fraud reasons.
If you have reverse DNS setup for a static IP dedicated to your webserver you could resolve this.

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 mailer is not working hotmail

<?php
$to = 'xyz#hotmail.com';
$subject = 'the subject';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: acb#gmail.com' . "\r\n" .
'Reply-To: acb#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = 'hi hello';
mail($to, $subject, $message, $headers);
echo 'mail sent';
?>
As I am sending mail using above code .. it is working fine ..
but mails are not going to hot mail...
can anyone help me in this please
This can be a plethora of things. One of the more common ones is that you are telling them you are sending mail from a gmail account but are not actually connecting to them from a gmail server.
If you could provide us with more information (specifically, lines concerning delivery from your mail.log) we could help better but most likely it is either that you aren't allowed to send mail for gmail and/or that your server is marked as "bad" by hotmail.
The hotmail spam filter stopped it, and with good reason. Advise i can give you:
Send it to yourself, and see the raw message. You may find that the From: address has changed and differs form the Reply-To:. To avoid that, send the email via SMTP instead.
If the domain you send from has a SPF DNS record, that may help. Spam filters use this to look up the authenticity of emails that claim to come from a certain domain.
This is why the #gmail.com address you used is certainly not going to pass through..

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.

from address come with server extension in mail

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!

Categories