PHP mail function does not work with some mail server [duplicate] - php

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I have made a password recovery option in my website using php mail function. It works with gmail and yahoo but when the email is hotmail it does not works, I tried many time. When I tried with my companies email (outlook) nothing happens. It only works with gmail and yahoo. What can be wrong with it. the code I am using is her below:
$email= "customer_email_address";
$head = "From: \"Pizza Hut Pakistan\" <no-reply#pizzahut.com.pk>\n";
$head .= "X-Mailer: RegFormPHP\n";
$head .= "Priority: urgent\n";
$head .= "Importance: High\n";
$head .= "Content-Language: en-us\n";
$head .= "Reply-To: <no-reply#pizzahut.com.pk>\n";
$head .= "Organization: \"Pizza Hut Pakistan\"\n";
$head .= "Content-Type: text/html\r\n";
$msg = 'Click the link below to proceed <br><br>';
$msg .= 'http://'.$_SERVER['HTTP_HOST'].'/root_folder/forgotlink.php?id='.$unique_code_of_user;
mail($email, "website account password recovery", $msg, $head);
every thing is cool with gmail and yahoo. but..... nothing works with others....
Thanks

Hotmail is probably rejecting your emails thinking it's spam.
Hotmail is known to be a PITA when it comes to emails... You can check if you have correct DKIM and SPF parameters, see if your server isn't blacklisted, or better yet, use a mailing provider like MailChimp, SendGrid or similar to be sure your emails are sended in best conditions.
You can try class.phpmailer.php. It works for Yahoo, Hotmail, GMail,

Related

Not receiving emails from website after transferring to Namecheap [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
sadly, I find myself in need of your help again...
I recently changed my hosting provider to Namecheap (like a month ago) and today I just noticed that I'm not receiving emails sent through the contact form on my site amelicakes.com.
The PHP code of this form hasn't changed and the contact form worked perfectly on my previous hosting provider.
PHP for the contact form is below:
<?php header('Content-Type: text/html; charset=utf-8');
header('Content-Transfer-Encoding: 8bit');
if(isset($_POST['email'])){
$mailTo = "ameli_cakes#abv.bg";
$subject = "mail from web";
$body = "New message from web
<br><br>
FROM: ".$_POST['email']."<br>
NAME: ".$_POST['name']."<br>
SUBJECT: ".$_POST['subject']."<br>
COMMENTS: ".$_POST['message']."<br>";
$headers = "To: Ameli Cakes <".$mailTo.">\r\n";
$headers .= "From: Contact Form <contact#amelicakes.com>\r\n";
$headers .= 'Content-Type: text/HTML; charset=utf-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n";
//envio destinatario
$mail_success = mail($mailTo, $subject, $body, $headers);
}
?>
After talking with a Namecheap representative, they told me that "PHP debugging is out of their scope" and to check this link.
Guys... I tried but I have no idea what I'm doing, and before making my PHP form unusable I decided to revert back to the original version and ask for help here.
I think I need to send these emails to an email account hosted in their servers so I created contact#amelicakes.com but I don't know how to continue.
Whatever help you can provide would be greatly appreciated, keep in mind that my PHP knowledge is very limited.
Thanks in advance to whoever is reading this!
PS: Please do not close this as duplicate, I have checked the alternatives and I do not understand how they apply to my case, the code seems different.
In order to avoid issues related to spam it is possible to use in FROM
field only email hosted at our servers
https://www.namecheap.com/support/knowledgebase/article.aspx/9239/31/how-to-configure-contact-form-hosted-with-us.
You're allowing the from email to be whatever the client inputs which is an email most likely not held on the namecheap servers. You need to make sure that where $_POST['email'] is, there is an email that is on your namecheap account. So, for example:
$headers .= "From: Contact Form <contact#amelicakes.com>\r\n";

Contact form with Gmail account [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
Hi I am trying to create my contact form and link it up with my Gmail account which I have. I have been trying to use the normal simple way by creating a HTML form and PHP file so that I can use the mail() function to send the email but this does not seem to work at all.
I want to create a contact form which links to my Gmail account and works when I host it on my server which is godaddy. This is driving me insane for the past 4 hours!!
Gmail is not the only mail service that will ignore sendmail emails.
If you're using 3rd-party hosting, you should find out the host name (e.g. "myhost.com") and use that in your From: header. Then use the correct email address in the "Reply-To" header instead.
Just for example:
$mailheader .= "Reply-To: Some One <someone#mydomain.com>\r\n";
$mailheader .= "Return-Path: Some One <someone#mydomain.com>\r\n";
$mailheader .= "From: Some One <mydomain#myhost.com>\r\n";
$mailheader .= "Organization: My Organization\r\n";
$mailheader .= "Content-Type: text/plain\r\n";
To increase deliver ability, you should use SMTP to send a mail via an actual email account.

PHP mail() - marked as spam [duplicate]

This question already has answers here:
Gmail and Hotmail marked as spam
(5 answers)
Closed 8 years ago.
My emails that are send by mail() are getting directly into the spam box, tested with GMAIL and HOTMAIL.
So:
I have dedicated server
My server ip is not listed on any blacklists
This is my code:
function send_email($recipient, $sender, $subject, $email_body){
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$sender;
mail($recipient,$subject,$email_body,$headers);
}
$from = 'info#domain.com';
$subject = 'subject';
$email_body = '<h1 style="text-align:center;">Title</h1><p>Message</p>';
send_email($userbday['email'], $from, $subject, $email_body);
Any thoughts?
Try to setup an SPF record for your domain.
Also
Email is serious business.
Try transactional email service providers
It may be that your email looks exactly as spam. It sometimes happens...
All my applications sends email - depending on how the client prepare the email templates - some are treated as spam almost instantly, some not.
Setting SPF Record can help, but also check (and use) some blacklist emails for your own good - like people who dont want to receive your emila should never be bothered again as they can trigger your server to be in the black lists (for example spamcop).

Sent mail from php goes into spam folder [duplicate]

This question already has answers here:
Prevent sent emails treated as junk mails using php mail function
(14 answers)
Closed 9 years ago.
I used this tutorial for sending mail :
http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/
My code looks like this :
$headers .= "Reply-To: The Sender <sender#sender.com>\r\n";
$headers .= "Return-Path: The Sender <sender#sender.com>\r\n";
$headers .= "From: The Sender <senter#sender.com>\r\n";
$headers .= "Organization: Sender Organization\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n"
mail("recipient#recipient.com", "Message", "A simple message.", $headers);
I am using localhost(MAMP PRO) for sending mail.
But mail goes to spam folder.How to send mail which goes to inbox.Please guys help me out from this,i spend a lot of time on it.
Which folder an email goes into depends mostly on the domain & ipaddress from which the email is coming from and the email service provider. If your domain/ip is trusted by the service provider it will not be spammed.
Also, after setting a few emails as "Not Spam" from that domain, your email service will no longer spam the emails
there are more than one reason ur email goes to spam ...
1 - make sure that the "from email" is actually the email u are sending the emails from .. i mean dont use any other false "from Email"
2- you have to keep the message body simple as possible . dont use so much html tags and css experssions , and also try to use tables

php mail function not sending email to gmail account only

i am facing a weird problem in my php script. i have made a function to send email and calling the function in my php page. the function works fine when i send mail to yahoo or any other domain but fails when it comes to send mail to the gmail account.below is my code
function send_mail($p_to , $p_sub, $p_body)
{
$from = 'xxx#mydomain.com';
$to = $p_to;
$email_subject = $p_sub;
$email_body = $p_body;
$xheaders = "";
$xheaders .= "From: <$from>\n";
$xheaders .= "X-Sender: <$from>\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
$xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
mail($to,$email_subject,$email_body,$xheaders);
}
//
when i send mail directly to a gmail account for example if a create a new page with the above code by taking hardcoded values for all the fields($p_to,$p_subject,$p_body) and sends mail then it works .
it was working fine earlier and sending mails to gmail account but, somehow stopped working for gmail.i checked the spam bucket also but found nothing.
any idea frnds ???
Google marks all not verified domains as blacklisted, so your email will be directly moved to the spam box of the gmail user. I think the only thing you can do is to send a mail to the customer service of google and ask if they can verify your domain as safe, but only if you find it really important that gmail users get it in their inbox and not in their spam box.
problem was sorted out. server side modification needed.
Thanks for your replies guys :)

Categories