php mail does not work with no-gmail address [duplicate] - php

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
I have part of my project when my clients will reseive mail after so many actions, when I testing my mail function, I have problem when the adresse is to "gmail" , I reseive the mail, but when the mail is no-gmail, the mail not reseived !!! :( this is my mail function:
function emailDemande($email, $name, $nameL){
$subject = 'Votre demande ';
$headers = "From: XXX <contact#emoovio.com>\r\n";
$headers .= "Bcc: abdelkhalek.oumaya#gmail.com, TEST#DOMAIN.com\r\n";
// $headers = 'From: XXX <'. $from. '>\r\n';
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message='htmlmessage';
mail($email, $subject, $message, $headers);
};

Mail is very complex in his flow.
Your Mail Headers and Content
Does the sender mail address exist as mailbox or as forwarder? Sending mail with a non-existent mail address goes wrong.
What about the mail headers, subject and body? More info: https://sendgrid.com/blog/10-tips-to-keep-email-out-of-the-spam-folder/
The Sending Mail Server
Be sure the sending server (the smtp server) knows and allows the sender mail address to mail from.
Blacklist
Check if your smtp server is blacklisted. More info: http://mxtoolbox.com/blacklists.aspx
External Mail Service
I recommend to use external mail services, like Mailgun (http://mailgun.com). Mailgun provides an API for sending, receiving and tracking mail. A great advantage is that your own mail server (or global ip) cannot be blacklisted.
For testing your mail functionality, you can use Mailtrap (https://mailtrap.io).

Related

PHP mail() from email and replyto adds server address [duplicate]

This question already has answers here:
How do you make sure email you send programmatically is not automatically marked as spam?
(24 answers)
Send email using the GMail SMTP server from a PHP page
(16 answers)
Closed 4 years ago.
I currently have a php script to send emails from Ubuntu server with sendmail.
$to = $sendTo;
$subject = $subjectPrefix . $subject;
$txt = $message;
$headers = array(
"From: ". $email,
"Reply-To: ".$email,
"Content-type:text/html;charset=UTF-8",
"MIME-Version: 1.0",
"X-Mailer: PHP/" . PHP_VERSION
);
$headers = implode("\r\n", $headers);
if(mail($to,$subject,$txt,$headers)){
echo "sent";
}
else {
echo "failed";
}
The emails send fine but always go into spam and have the server address attached to the email, for exmaple: "input#email.com"#ip-###-##-##-###.eu-west-2.compute.internal
How would i go about setting this to only show the input email and not go into spam?
It's because the mailserver you're using to send your email does not belong to the domain of the sender, and is therefore not a 'trusted' source.
You can use SMTP server of your email's domain. For example, if you want to use email from Google's Gmail Service as From address , you have to use the Gmail SMTP server.
So, you can add SMTP email rely for SendMail. How to do it you may read here
Also, you can install SMTP client msmtp and configure PHP for using it. Instructions here
At last, if you don`t want to configure your server, you can use PHPMailer library.

How can I send email from this code, I am trying to send emails from localhost xampp server [duplicate]

This question already has answers here:
Send email using the GMail SMTP server from a PHP page
(16 answers)
Closed 4 years ago.
<?php
if (isset($_POST["send"])) {
$to = $_POST["to"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers = "From: your#email-address.com\r\n";
if (mail($to, $subject, $message, $headers)) {
echo "SUCCESS";
} else {
echo "ERROR";
}
}
?>
This is my php code, I have a HTML form and $to, $subject, $message is the input fields of the form, the $_POST["send"] is the button through which I want to send emails after clicking that button
You can't send emails from your localhost server. Get a free PHP server and upload your files using ftp. Following are some free php server providers where you can test your project.
000webhost
Infinity Free
That's true, you can't send emails from localhost, unless you were using a VPS configured with DNS + public IP + email server;
If isn't your case, I would recommend sending emails through a SMTP server:
PHP Mail (php.ini configuration)
PHPMailer (library)
For the SMTP server you could use any provider that allows SMTP.

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

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,

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).

why the mail function not working

Why the mail function not sending mail to me ,Could any one please help me ?
Here i have wrote script to mail sending.
Is there any other settings to send mail.
But the mail function printing always "Success" , but the mail not received to me.
$Msg = "Your Suggestion is saved successfully. Please wait for admin approval";
$subject="New Suggestion Posted - Waiting for approval";
//$email_id = 'bajrang.lal#sunarctechnologies.com';
$email_id = 'bajrang.lal#sunarctechnologies.com';
$mail_msg="Hello Admin,<br><br>New Suggestion Posted. Waiting for approval.<br><br>
Suggestion : ".$frmdata['description']."<br><br> Click here for <a href='http://www.tatanykshipping.com/index.php'>login</a><br><br> Thanks,<br>The TATA NYK Team";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Tata NYK <".$_SESSION['EMAIL_ID'].">\r\n";
$headers .= "Organization: Tata NYK\r\n";
echo '<br>sending mail to = ',$email_id;
if(mail($email_id,$subject,$mail_msg,$headers))
echo '<br>Successs';
else
echo '<br>Fail';
Thanks a lot in advance.
If your PHP application is running on Linux and expecting to send mail from that system, you need a transport. I use sendmail, but there are other open source transports you can use. You may also have to install an email client, but I do not know how PHP interacts with sending mail. My applications act like an email client, and need the email client installed.
You also need to make sure that the email recipient will accept unsolicited port 25 traffic. Because of spam-ware, our firewall won't accept unsolicited port 25 traffic, so I have doctored up sendmail to log into our email server as a legitimate email account.

Categories