Return to Snippet

Revision: 39519
at January 18, 2011 04:09 by kendsnyder


Initial Code
function sendHtmlEmail($recipient, $subject, $html) {
	// Need PEAR in include path with installed: Mail, Net_Smtp
	$headers = array(
		'From' => 'whateveremail',
		'Reply-To' => 'whateveremail',
		'Cc' => 'whateveremail',
		'MIME-Version' => '1.0',
		'Content-Type' => 'text/html; charset=UTF-8',
		'To' => $recipient,
		'Subject' => $subject,
	);
	$smtp = Mail::factory('smtp', array (
		'host' => 'smtp.server.whatever',
		'port' => 25,
		'auth' => true,
		'username' => ,
		'password' => )
	);
	
	$mail = $smtp->send($recipient, $headers, $html);

	if (PEAR::isError($mail)) {
		trigger_error($mail->getMessage(), E_USER_WARNING);
		return false;
	}
	return true;
}

Initial URL


Initial Description


Initial Title
Send SMTP emails with PEAR

Initial Tags
email

Initial Language
PHP