amandeep.sandhu
06-01-2006, 11:32 AM
function sendMail($to, $name, $subject, $from, $message)
{
$headers ="MIME-Version:1.0\r\n";
$headers .="content-type:text/html; Charset=iso-8859-1\r\n";
$headers .= "From: " . "$name" . "<" . "$from" . ">\n";
$headers .= "Return-Path: <" . "$to" . ">\n";
$headers .= "Error-To: <" . "$to" . ">\n";
$headers .= "X-Sender: <" . "$to" . ">\n";
$headers .= "X-Mailer: PHP v".phpversion()."\n";
$subject= nl2br($subject);
$message=nl2br($message);
$to=$to;
$mail= mail($to, $subject, $message, $headers) ;
return $mail;
}
// How To Use
$to="amandeep.sandhu@yahoo.com";
$from="karan@yahoo.com";
$name="karan";
$subject="hello";
$message="How r u";
sendMail($to, $name, $subject, $from, $message);
You can Place function sendMail in a separate file like functions.php and then include functions.php in your current file and call function sendMail in other file. With this if you have to send email in multiple forms you have to call sendMail($to, $name, $subject, $from, $message); only.
You can Pass $to, $from , $name, $subject, $message to this function and send email to anybody.
Thanks.
{
$headers ="MIME-Version:1.0\r\n";
$headers .="content-type:text/html; Charset=iso-8859-1\r\n";
$headers .= "From: " . "$name" . "<" . "$from" . ">\n";
$headers .= "Return-Path: <" . "$to" . ">\n";
$headers .= "Error-To: <" . "$to" . ">\n";
$headers .= "X-Sender: <" . "$to" . ">\n";
$headers .= "X-Mailer: PHP v".phpversion()."\n";
$subject= nl2br($subject);
$message=nl2br($message);
$to=$to;
$mail= mail($to, $subject, $message, $headers) ;
return $mail;
}
// How To Use
$to="amandeep.sandhu@yahoo.com";
$from="karan@yahoo.com";
$name="karan";
$subject="hello";
$message="How r u";
sendMail($to, $name, $subject, $from, $message);
You can Place function sendMail in a separate file like functions.php and then include functions.php in your current file and call function sendMail in other file. With this if you have to send email in multiple forms you have to call sendMail($to, $name, $subject, $from, $message); only.
You can Pass $to, $from , $name, $subject, $message to this function and send email to anybody.
Thanks.