0

I'm having a very strange issue I've never encountered before with the mail() function in php when trying to send html.

My issue is that when I'm trying to send the text "GBI - Credit Note Testing" there is no errors but I am also not receiving the email. The weird part about it, is that it is specific to the text I am trying to send, for example, if I change the text to "GBI - Note Testing" there is no issue, or even "GBI - Credi Note Testing" (note the missing 't') works too.

Changing the text works fine it's just the specific sentence is not working and it's really confused me.

$message = "<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<table>
<tr>
<td>GBI - Credit Note Testing
</td>
</tr>
</table>
</body>
</html>";

$to = $email;
$subject = "Test";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headers .= "From: Me"."\r\n";

mail($to,$subject,$message,$headers);

Im expecting this text to be sent with no issues but it only sends when I change the text

  • 3
    Is it being delivered as Spam? The word `Credit` is a very suspicious term (credit and banking scams) and could get you flagged, especially if your sending domain is not otherwise very robustly configured in DNS as a mail sender. – Michael Berkowski Feb 15 '19 at 12:04
  • I strongly advice using PHPMailer instead of writting your own code where many things can go wrong like header injections – Raymond Nijland Feb 15 '19 at 12:05
  • As @MichaelBerkowski says, have you checked your spam? – Ishaan Feb 15 '19 at 12:06
  • Check [this answer](https://stackoverflow.com/questions/11238953/send-html-in-email-via-php). Also maybe the `From` header is obligatory. If thats not the case I dont see a reason in that code snippet why it wouldn't work. Is sendmail configured correctly? Is your mailserver configured to reject sending HTML Mails? – Marco Feb 15 '19 at 12:08
  • Check the logs on all the MTAs between the script and MUA. – symcbean Feb 15 '19 at 12:52

0 Answers0