通过PHP发送邮件中的HTML? [英] Send HTML in email via PHP?

查看:169
本文介绍了通过PHP发送邮件中的HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用PHP发送带有图片的HTML格式的电子邮件?
我想要一个页面,一些设置和一个HTML输出,通过电子邮件发送到一个地址。我该怎么办?
主要的问题是附加文件,我可以这样做吗?

How can I send a HTML format email with pictures using PHP? I want to have a page with some settings and a 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']) . "\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";

这是链接我得到的信息..( link ...

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

你将需要安全...

这篇关于通过PHP发送邮件中的HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆