Page 1 of 1

Send Email Function

Posted: Tue Apr 25, 2006 2:50 am
by dibyendrah
Customized function to send email.

Code: Select all

// Function to Send out Email
function Send_Email($sFrEmail, $sToEmail, $sCcEmail, $sBccEmail, $sSubject, $sMail, $sFormat)
{
	/* recipients */
	$to  = $sToEmail;

	/* subject */
	$subject = $sSubject;

	$headers = "";

	if ($sFormat == "html") {
		$content_type = "text/html";
	} else {
		$content_type = "text/plain";
	}

	$headers = "Content-type: " . $content_type . "\r\n";

	$message = $sMail;

	/* additional headers */
	$headers .= "From: " . $sFrEmail . "\r\n";
	if ($sCcEmail <> "") {
		$headers .= "Cc: " . $sCcEmail . "\r\n";
	}
	if ($sBccEmail <>"") {
		$headers .= "Bcc: " . $sBccEmail . "\r\n";
	}

	/* and now mail it */
	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
		ini_set("SMTP","localhost");
		ini_set("smtp_port","25");
	}
	ini_set("sendmail_from",$sFrEmail);
	mail($to, $subject, $message, $headers);

}

Cheers,
Dibyendra