Jump to content

mail() issue


Letterbomb05

Recommended Posts

Hi,

 

$to = $_POST['email'];
$subject = "You have registered";
$body = "
<html>
<head>
<title>Account Activation</title>
</head>
<body>
<p>email here <br />
<br />
-----------------------------<br />
This is an automated email, please don't try and reply.'
</body>
</html>";

$headers  = 'MIME-Version: 1.0' . "\r\n\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n\n";
$headers .= 'To: '.$username.' <'.$to.'>' . "\r\n";
$headers .= 'From: website.com <[email protected]>' . "\r\n\n";
$headers .= 'Cc: [email protected]' . "\r\n\n";
$headers .= '[email protected]' . "\r\n\n";

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

 

My problem here is with the headers. I've followed the manual to using mail() on php.net it just doesn't seem to work!

Notice I have '\n\n' on the end of each header, if i only use one \n, the email doesn't send atall, however with the two, the email DOES send

but with issues. The problem is that when I recieve the email, the headers are simply displayed at the top of the email, they arn't actually put into use :X

Thanks in advance for any help :)

Link to comment
https://forums.phpfreaks.com/topic/117942-mail-issue/
Share on other sites

$to = $_POST['email'];
$subject = "You have registered";
$body = "
<html>
<head>
<title>Account Activation</title>
</head>
<body>
<p>email here <br />
<br />
-----------------------------<br />
This is an automated email, please don't try and reply.'
</body>
</html>";

$headers = 'From: website.com <[email protected]>';
mail($to, $subject, $body, $headers);

 

What happens if you do that?

 

----------------

Now playing: Linkin Park - Crawling Demo

via FoxyTunes

Link to comment
https://forums.phpfreaks.com/topic/117942-mail-issue/#findComment-606723
Share on other sites

I need all the headers?

 

 

You really can never had too many good headers that is what email servers read when they decide to allow a message in or bounce it

 

'MIME-Version: 1.0' . "\r\n\n";                                        Important and always required

'Content-type: text/html; charset=iso-8859-1' . "\r\n\n";    Required for your html message

'To: '.$username.' <'.$to.'>' . "\r\n";                                Again important 

From: website.com <[email protected]>' . "\r\n\n";        Important

'Cc: [email protected]' . "\r\n\n";                              Not really important

'[email protected]' . "\r\n\n";                                    Not really important

 

 

Link to comment
https://forums.phpfreaks.com/topic/117942-mail-issue/#findComment-606766
Share on other sites

the \r\n (only 1 \n is required) are necessary because servers read headers separated by break lines and unix new lines are one of those (I think \r) and windows are \n  so you need to make both server types happy.

 

 

As for what you wrote the connotation isn't needed on the first instant of $header (the .=  should just be  $header  =)

 

 

I really don't know what you are asking?

 

 

http://en.wikipedia.org/wiki/E-mail

 

the image there shows you why headers are important

Link to comment
https://forums.phpfreaks.com/topic/117942-mail-issue/#findComment-606792
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.