通过 PHP 在电子邮件中发送 HTML [英] Send HTML in email via PHP
问题描述
如何使用 PHP 发送带有图片的 HTML 格式的电子邮件?
How can I send an HTML-formatted email with pictures using PHP?
我想要一个包含一些设置和 HTML 输出的页面,该页面通过电子邮件发送到某个地址.我该怎么办?
I want to have a page with some settings and HTML output which is sent via email to an address. What should I do?
主要问题是附加文件.我该怎么做?
The main problem is to attach files. How can I do that?
推荐答案
很简单,把图片留在服务器上,然后把 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']) . "
";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "
";
$headers .= "CC: susan@example.com
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=UTF-8
";
$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
";
这是我得到信息的链接..(链接...)
Here is the link I got the info.. (link...)
不过你需要安全...
这篇关于通过 PHP 在电子邮件中发送 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!