php mail()函数:如何在html消息中显示图像和使用样式 [英] php mail() function: How to display images and use style in html message

查看:63
本文介绍了php mail()函数:如何在html消息中显示图像和使用样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在php mail()函数方面遇到问题.第一个问题是某些电子邮件浏览器(例如gmail)无法自动显示图像.第二个问题是消息没有使用我在<p style>

I'm currently having an issue with the php mail() function. The first issue is that some e-mail browsers, like gmail, are not displaying the images automaticly. The second issue is that the message is not using the style I put in <p style>

这是仅用于php mail()函数的'message'部分的代码.其余的不需要(如果需要,请告诉我).

Here is the code only for the 'message' part of the php mail() function. The rest isn't needed (and if it is, please let me know).

我不使用phpMailer,因为我完全不熟悉它,我是代码的初学者,最后这部分代码只是脚本的一小部分.

I am not using phpMailer because I am not familiar at all with it, I'm very beginner in code and finally this part of the code is a little part of a script.

$message = '<html><body><center>';
$message .= '<img src="http://externet.website/mail/images/logo.png" alt="Mogingo" />';
$message .= '<br /><p />';
$message .= '<img src="http://externet.website/mail/images/orangebar.png" alt="Spacer" />';
$message .= '<p style="font-family:"Comic Sans MS";font-size:60px"><strong>Bonjour!</p></strong>';
$message .= '<p style="font-family:"Sans Serif";font-size:22px">Merci d’avoir utilisé les services de gestion de projet de Mogingo, nous apprécions votre confiance. Votre facture est disponible en cliquant sur lien ci-dessous:</p>';
$message .= '<p style="font-family:"Sans Serif";font-size:22px">';
$message .=  $_POST['URL-main'];
$message .= "</p>";
$message .= '<p style="font-family:"Sans Serif";font-size:22px">Si vous avez apprécié l’expérience, n’hésitez pas à en parler dans votre réseau : nous avons un programme de récompense de 10% de rabais sur votre prochaine facture lorsque vous nous référez un nouveau client !';
$message .= '<p style="font-family:"Sans Serif";font-size:22px">Au plaisir de faire affaires avec vous,<p>';
$message .= '<p style="font-family:"Sans Serif";font-size:22px">- L’Équipe de Mogingo</p>';
$message .= '<img src="http://externet.website/mail/images/orangebar.png" alt="Spacer" />';
$message .= '</body></center></html>';

感谢您抽出宝贵的时间阅读并希望提供答案.

Thank you for taking time to read and hopefully provide answer.

EDIT

EDIT

我已解决通过以下方式显示图像的问题: -我现在使用PHPMailer,它更加容易. -您需要添加以下几行

I have fixed my issue of showing my images the following way: - I now use PHPMailer which is much more easier. - You need to add the following lines

$mail->AddEmbeddedImage("../images/logo.png", 'logo');

然后您可以使用

$message .= '<img src="cid:orangebar" alt="Spacer" />';

推荐答案

听起来像PHPMailer的工作.. http://phpmailer.worxware.com/ 安装完成后,请使用像这样的示例 http://phpmailer.worxware.com/index.php?pg=exampleamail 构建带有嵌入式附件的HTML电子邮件

Sounds like a job for PHPMailer.. http://phpmailer.worxware.com/ Once installed, use the examples like this one http://phpmailer.worxware.com/index.php?pg=exampleamail to construct an HTML email with inline attachments

这篇关于php mail()函数:如何在html消息中显示图像和使用样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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