Reputation: 515
I've been using this script for about 2 months and everything was working properly. Today I was adding new functionalities related to sending an email and I noticed that the emails sent to gmail were having some problems, but only on gmail. Instead of receiving a regular message (text/html) I receive a file named "no name.html" with the message sent.
Here's my code:
$from = "My name <[email protected]>";
$email = "[email protected]"
$to = "";
$subject = "Subject Here";
$host = "smtp.gmail.com";
$username = "[email protected]";
$password = "passwordhere";
$headers = "";
$smtp = Mail::factory('smtp', array('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$body = "<div>Hello World</div>";
$to = "<" . $email . ">";
$headers = array('From' => $from,
'To' => $to,
'Subject' => $subject,
"MIME-Version" => "1.0",
"Content-Type" => "text/html charset=\"ISO-8859-1\"",
"Content-Transfer-Encoding" => "8bit");
$mail = $smtp->send($to, $headers, "<html><head><meta http-equiv=\"Content-type\"
content=\"text/html;charset=UTF-8\"></head><body>" . $body . "</body></html>");
Upvotes: 0
Views: 206
Reputation: 2048
I don't if it is the reason of your problem, but:
In your header, you have a charset ISO:
"Content-Type" => "text/html charset=\"ISO-8859-1\""
And in the html content, UTF-8 :
<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">
Upvotes: 1