Forum Moderators: coopster

Message Too Old, No Replies

PHP send/receive emails

A fight with Norton (I won!)

         

henry0

2:32 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After two days of struggle and experiencing with script mods I finally made it, passing through Norton spam filter.
My site is by no means a spamming outfit, and I am banned by none.
But mails sent from my server were recently considered by Norton as spam, although delivered but with extra headers and killed html
so here is sample to keep in case you run through the same "ordeal"

<?php

$admin="admin@aaaaa.net";
$to=trim($admin,"'");
$subject="asasasas";

$message="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
'http://www.w3.org/TR/html4/loose.dtd'>
<html><head>
<meta http-equiv='Content-Type' content='text/html'; charset=UTF-8'
<title>Message from asasas</title>
</head>

<body><p><b>asasas</b></p>
<p>Category is: aaa </p>
<p>Page url is: ddd
<p>Review it and if OK set activated to yes</p>
</body></html>";

$header = 'MIME-Version: 1.0' .PHP_EOL;

$header .= 'Content-type: text/html; charset=iso-8859-1' .PHP_EOL;

$header .= "From: " . $admin .PHP_EOL;

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

?>

penders

4:29 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Glad you got it sorted and thanks for posting! Just a couple of queries though (this maybe a typo)... you're Content-Type meta tag is incorrectly formed and not closed which could potentially cause problems with other email clients:

<meta http-equiv='Content-Type' content='text/html'; charset=UTF-8'


I would have thought should be:
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>


PHP_EOL... This is server OS specific, so whilst this might work on your server, it might not work on another. I think on most systems, to separate the headers, this should probably be "/r/n".

rocknbil

5:05 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You meant \r\n. :-)

I'd never had any trouble like so. Is utf-8 better for html emails (considering non-English recipients I guess it would be . . . )?

$headers = "From: $from\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

henry0

5:11 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@Penders, Thanks, yes, is a typo!
@rocknbill, -8, was part of my tests, I must say done the empiric mode, test ... come with a few explicit, test again and this seems to work fine. By the way JaguarPC has no clue on such a problem :)

penders

5:55 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You meant \r\n. :-)


Indeed, thanks! :)

Readie

6:57 pm on Nov 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



this should probably be "/r/n"


A while ago, we had a problem at work where on *some* html capable email programs, the mails sent from our server was being interpreted as plain text.

The problem was eventually solved by changing the "\r\n" in the header declarations to "\n".

Now, this problem only occured on one of our servers. Both of our servers are LAMP, same versions of all software, same plugins installed etc, so I can only presume there was one setting somewhere that was different to cause this. But yea, something to bear in mind :)