2
我有一个代码与我用于发送PHP电子邮件给我的收件人。我找到了一种方法,通过在标题的部分中包含'Content-Type'=>“text/html”来向他们发送HTML电子邮件。我的问题是,如何收到我的电子邮件,谁不能显示HTML电子邮件?他们会看到HTML代码?如果是这样,我的邮件应用程序如何决定,何时发送平原以及何时发送HTML格式?发送电子邮件与PHP和SMTP - 文本和HTML
这里是我的代码,例如:
<?php
require_once "Mail.php";
$from = "Example <[email protected]>";
$to = "[email protected]";
$subject = "Hi!";
$body = '<html>This is a HTML message...</html>'
$host = "smtp";
$username = "user";
$password = "pass";
$headers = array ('From' => $from,
'To' => $to,
'Content-Type' => "text/html",
'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("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
https://pear.php.net/manual/hu/package.mail.mail-mime.example.php – CBroe