php mail spam problems [duplicate] - php

This question already has answers here:
sending email via php mail function goes to spam [duplicate]
(6 answers)
Closed 7 years ago.
$to = $_POST['email'];
$subject = 'Your password';
$message = $_POST['password'];
$headers = 'From: https://client.yourtradechoice.com/ no_reply#yourtradechoice.com' . "\r\n" ;
$headers .='Reply-To: '. $to . "\r\n" ;
$headers .='X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($to, $subject, $message, $headers);
mail sending in spam how to fix it ?

Don't use php mail function to send email. Use php mailer script like Swiftmailer & use SMTP server to send emails.

Related

PHP xammp sendmail error: Message is missing sender's address [duplicate]

This question already has answers here:
php single and double quotes
(2 answers)
Closed 1 year ago.
I have set up the Sendmail client on my localhost xammp server running on my home pc but I am getting the following error:xx-xx-xx xx:xx:xx: Message is missing sender's address. I have gotten it to work when I use the hard code what I want to send, like so:
$msg = "hello world";
mail("example#gmail.com","My subject",$msg, 'From: admin#myEmailClient.com');
but when I try and implement my login validation script It does not work and I get the aforementioned error.
emailvalidation.php
$to = $email;
$sub = 'email verification';
$msg = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$headers = "From: admin#myEmailClient.com \r\n";
$headers = "MIME-Version: 1.0". '\r\n';
$headers = "Content-type:text/html;charset=UTF-8 ". '\r\n';
mail($to, $sub, $msg, $headers);
my email variable is set by the user if that helps, I don't think its a problem with the items being parsed because when I check my database all rows are properly filled in.
thank you for your time
edit
I think it's a problem with the r\n parts, these are the parts that enable HTML in emails. when I get rid of them it works
I'm not sure if I should delete this question because of the speed I was able to solve it but I hope this helps someone who had the same problem as I did.
here is how I solved the problem
$message = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$to = $email;
$subject = 'account validation';
$from = 'admin#myEmailClient.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
header("location: index.PHP");
}
I got the solution from here. tutorial republic

PHP mail function is not working after "from" header is added [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 3 years ago.
I'm sending email using php header.
$to = 'test#email.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = '<h1>Test</h1>';
mail($to, $subject, $message, $headers);
This function is working properly.
But after I added "From" mail() function is not working.
$headers .= "From: from#address.com";
Any idea?
May you are trying to spoof email, so it's getting failed.
It would be great practise to keep using Reply-To with From while using mail()
$headers .= "From: from#address.com\r\n";
$headers .= "Reply-To: from#address.com\r\n";
But, personally suggest you to use SMTP instead of mail() or PHPMailer.

Mail sending error PHP, didn't get message [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 5 years ago.
This is my code. I spent hours debugging it. I can't see the error. Why didn't I didn't receive the email?
if(isset($_POST['submit'])){
$to = "admin#example.com";
$subject = "Mesej Website";
$from = $_POST['email'];
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<h3>Mesej Daripada '.$_POST['name'].'</h3>';
$message .= '<div style="margin-top:20px;">'.$_POST['message'].'</div>';
$message = '</body></html>';
mail($to,$subject,$message,$headers) or die('mail sending error');
The in built mail function of PHP needs configuration for sending the email.However, if you are using the third party hosting provider this should be already configured or else you need to configure it in php.ini file.
To avoid these configuration issues you can use the phpmailer library where you can all the parameters easily and in a more efficient way.

mail() function not working for domain mail address [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I am trying to use php mail() function on my new web server(linux based server) for my website. The issue is, emails are not sending to domain email addresses like some1#domain.com but its working fine for gmail, yahoo. I don't know what is the issue on it?. please give me suggestions or advice how to solve this issue. I want to send emails to domain-based email addresses.
my code is
//$to = $_POST['femail'];
$to = "<toadd#domain.com>";
$message = "
<html>
<head>
<title>".$subject."</title>
</head>
<body>
<p>Registration request from site</p>
<table>
<tr>
<td>Project Requested</td>
<td>".$project."</td>
</tr>
</table>
</body>
</html>";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <info#domain.com>' . "\r\n";
$headers .= 'Cc: <some#domain.com>' . "\r\n";
$headers .= 'X-Mailer: PHP/' .PHP_VERSION. "\r\n";
#mail($to,$subject,$message,$headers);
I have faced the same issue..after a talk with hosting service provider I came to know that either sender or receiver's email id should be of the hosting domain id like if you have a site test.com either sender or receiver should have #test.com so you may do the same or talk to your hosting service provider.
$to = "toadd#domain.com"; //to address
$subject ="Your Subject";
$message = "Your message";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: info#domain.com' . "\r\n"; //from address
if (mail($to, $subject, $message, $headers) )
{
echo "Mail sent successfully";
}
else
{
echo "failed to send mail";
}

mail() function doesn't not send infomation to my email [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
Here is my code:
<?php
header('Content-type: text/plain; charset=utf-8');
$to = 'example#gmail.com';
$subject = 'Message to the site';
$realname = htmlspecialchars($_POST['realname']);
$email = htmlspecialchars($_POST['email']);
$msg = htmlspecialchars($_POST['msg']);
$headers = 'From: example#gmail.com' . "\r\n" .
'Reply-To: example#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $msg, $headers) or die("Error!");
echo 'Thank you! :)';
?>
Could somebody explaing me - why this code does not work properly?
I meant that, when I click button submit, it send the email, but I could not include $msg in it and I don't know why.
Try to add :
$headers .= 'Content-type: text/html';
Add this line under $headers and than check i hope this will work for you...

Categories