Templates – phpmailer

require_once("../../classes/class.phpmailer.php");

if(strlen($err) == 0 && $errCode == 0){
	try{
		$mail= new PHPMailer();
		$mail->From = $email;
		$mail->FromName = $user_name;
		$mail->Subject = $subject;
		$mail->Body = $content;

		$mail->ClearAllRecipients();
		foreach($contacts as $contact){
			$mail->AddAddress($contact['url'], $contact['title']);
		}

		$result = $mail->Send();
		if(!$result) throw new Exception("目前無法寄送電子郵件,請稍侯再試");
	}catch(Exception $e){
		$err = $e->getMessage();
		$errCode = 9;
	}
}