通过PHP在电子邮件中发送HTML [英] Send HTML in email via PHP

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

问题描述

如何使用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']) . "\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...

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

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