Jump to content

Mail() Script OK?


Chunk1978

Recommended Posts

hi there... i would like to know if anyone could look at my mail script and tell me if there is anything clearly wrong, or missing... this is my first attempt at writing a mail script.

 

<?php
$name = $_POST['name'];
$to = $_POST['email'];
$subject = 'test';
$random_hash = md5(date('r', time())); 

$headers = "From: [email protected]\nReply-To: [email protected]";
$headers .= "\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 

ob_start();
?>

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/plain; charset="iso-8859-1" 
Content-Transfer-Encoding: 8bit

<?php
echo nl2br ("hello $name.\nthis is a basic text email message.\nYour Email doesn't accept HTML email.");
?>

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/html; charset="iso-8859-1" 
Content-Transfer-Encoding: 8bit

<?php
echo ("hello $name.<br><h2>this is an HTML email</h2>");
echo ("<p>Your email accepts <b>HTML</b> formatting.</p>");
?>

--PHP-alt-<?php echo $random_hash; ?>--



<?php
$message = ob_get_clean();
mail ($to, $subject, $message, $headers);

# after message is sent, goto Google.

header ("Location:  http://www.google.com");
?>

Link to comment
https://forums.phpfreaks.com/topic/46975-mail-script-ok/
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.