I\'ve been able to send an email using SMTP in PHP, but when I try to change the Content Type to HTML, the email doesn\'t get delivered. This is the code I\'m trying to use:
I did some research, then I made my own code to send mail with HTML formatting using SMTP authentication. See here:
Name:
'.$senderName.'
Company:
'.$_GET['txtCompany'].'
Phone:
'.$_GET['txtphone'].'
E-mail:
'.$senderEmail.'
URL:
'.$url.'
Massage:
'.$msg.'
';
$from = $senderName."<".$senderEmail.">";
$to = "Contact ManagerHR";
$subject = "Hi!";
$host = "XXX.host.com";
$username = "username@host.com";
$password = "*****";
/* MIME-Version should be "1.0rn" and Content-Type should be "text/html; charset=ISO-8859-1rn" to send an HTML Email */
$headers = array ('MIME-Version' => '1.0rn',
'Content-Type' => "text/html; charset=ISO-8859-1rn",
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("" . $mail->getMessage() . "
");
} else {
header('Location: '.$url); // redirect to url where from inquiry made
//echo("Message successfully sent!
");
}
?>