简体   繁体   English

用PHP发送HTML电子邮件

[英]Sending HTML email in PHP

I am working on an HTML page where i need to send confirmation by HTML email using PHP. 我正在开发一个HTML页面,我需要使用PHP通过HTML电子邮件发送确认。 I don't have much experience in PHP as i occasionally work on PHP. 我没有太多的PHP经验,因为我偶尔会使用PHP。

I am able to send the HTML email using PHP and it comes up nice except the IMAGE part. 我可以使用PHP发送HTML电子邮件,除了IMAGE部分外,它很好用。

I have checked about 30 example and implement different ways of but non works. 我已经检查了大约30个例子,并实现了不同的方法但不起作用。

When i check the source code of email it shows image part as 当我检查电子邮件的源代码时,它将图像部分显示为

<img src="http://www.xyz.com/images/emailheader.jpg\&quot;"> 
<img src="http://www.xyz.com/images/emailheader.jpg\&quot;;" alt="mage&quot;">

Code for HTML HTML代码

$subject = 'Confirmation';
$message = '<table ><tr><td><img src=\"http://www.xyz.com/images/emailheader.jpg\" /></td></tr><tr><td >'. "\r\n";
$message .= '<img src=\"http://www.xyz.com/images/emailheader.jpg\"; alt="Image" />';
$message .= 'Title <br/><br/>'. "\r\n";
$message .= 'Dear '. $_SESSION['FN'] . ' '.$_SESSION['LN'].'<br/><br/>'. "\r\n";
$message .= ' <br/><br/>'. "\r\n";
$message .= 'Name: '. $_SESSION['FN'] . ' '.$_SESSION['LN'].'<br/>'. "\r\n";
$message .= 'Email: '. $_SESSION['Email'].'<br/>'. "\r\n";


$message .= '<br/><br/>.'. "\r\n";

$message .= '<br/><br/>Best Regards,'. "\r\n";

$message .= '</td></tr></table>';

//Headers
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n";
$headers .= 'From: booking@xyz.com' . "\r\n";
$headers .= 'Reply-To: abc@xyz.com' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();

ini_set ( "SMTP", "smtp.abc.com" );

I would appreciate if some can correct my code or at-least tell me what i am doing wrong 如果有人可以纠正我的代码,或者至少告诉我我做错了什么,我将不胜感激

problem is in this line: 问题在于这一行:

'<img src=\"http://www.alfarooqcentre.com/images/emailheader.jpg\"; alt="Image" />';

remove "\\" and ";" 删除“\\”和“;”

or check this tutorial, there is what you want. 或者查看本教程,有你想要的。

http://phpform.net/html_mail.php http://phpform.net/html_mail.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM