电子邮件链接 php,PHP mail() – 如何在电子邮件中放置html链接?

参见英文答案 > Send HTML in email via PHP?                                    8个

我正在通过PHP的mail()函数发送电子邮件.在消息中,我设置了一个如下所示的链接:

$message = "" .$title. "\n\n";

但是,当收到电子邮件时,电子邮件正文显示html代码而不是标题作为超链接.我对html电子邮件不是很熟悉.我怎么能实现我想要的目标呢?

解决方法:

尝试添加标头,以便邮件客户端不相信它是纯文本:

$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

示例#4发送HTML电子邮件:

// multiple recipients

$to = 'aidan@example.com' . ', '; // note the comma

$to .= 'wez@example.com';

// subject

$subject = 'Birthday Reminders for August';

// message

$message = '

Birthday Reminders for August

Here are the birthdays upcoming in August!

PersonDayMonthYear
Joe3rdAugust1970
Sally17thAugust1973

';

// To send HTML mail, the Content-type header must be set

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers

$headers .= 'To: Mary , Kelly ' . "\r\n";

$headers .= 'From: Birthday Reminder ' . "\r\n";

$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";

$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it

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

?>

标签:html,php

来源: https://codeday.me/bug/20190927/1823638.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值