Cannot send PHP mail in text/html ?

Status
Not open for further replies.

rageon

New Member
Messages
3
Reaction score
0
Points
0
Hi all,
I notice PHP mail() function works well with text/plain mails but not with text/html. To be more specific, mail() returns okay but in fact mails are not sent at all.
Are there any specific reasons mail server will not deliver text/html mails ?

This is the code I used to test:
Code:
$from = "from"; 
$to="to";  
$mailbody="Test message sent (PST): \n" . date('l jS \of F Y h:i:s A'); 
$subject="Test of PHP mail()" ; 

$headers = "Content-type: text/html; charset=iso-8859-1 \r\n"; 
$headers .= "From: $from\r\n"; 
$headers .= "Reply-To: $from\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "X-Mailer: PHP/" . phpversion(); 


if( mail($to, $subject, $mailbody, $headers))
echo "success";
else
echo "failed";
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Too many members were abusing the system by sending phishing emails that were text/html.

So the decision was made to disallow text/html.
 

rageon

New Member
Messages
3
Reaction score
0
Points
0
I see, so this is deliberate, not a configuration error in my code.
Thanks.
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Too many members were abusing the system by sending phishing emails that were text/html. So the decision was made to disallow text/html.

I see, so this is deliberate, not a configuration error in my code.

I'm sorry for the misinformation but this is not true. We do not deliberately disallow specific Content-type or related headers from email messages sent from any of our services.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Then why does a plain email that is delivered with "text/plain" get swallowed with "text/html"?
 

rageon

New Member
Messages
3
Reaction score
0
Points
0
I don't understand... It matters that the "Content-type: text/plain" is specified in the headers for the emails to actually be sent. If it is for text/html, the mails will be silently discarded.
 
Status
Not open for further replies.
Top