且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过PHP在电子邮件中发送HTML

更新时间:2022-12-03 10:59:30

这很简单,将图像保留在服务器上,然后将PHP + CSS发送给它们...

It is pretty simple, leave the images on the server and send the PHP + CSS to them...

$to = 'bob@example.com';

$subject = 'Website Change Reqest';

$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

$message = '<p><strong>This is strong text</strong> while this is not.</p>';


mail($to, $subject, $message, $headers);

此行告诉邮件和收件人,电子邮件(希望)包含格式正确的HTML,需要解释:

It is this line that tells the mailer and the recipient that the email contains (hopefully) well formed HTML that it will need to interpret:

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

这是我获取信息的链接.(链接. .. )

Here is the link I got the info.. (link...)

尽管如此,您仍需要安全...

You will need security though...