CSS不工作的电子邮件发送使用AWS [英] css not working in email sending using AWS

查看:229
本文介绍了CSS不工作的电子邮件发送使用AWS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发PHP的一个网站,并希望将电子邮件发送给用户,当用户注册。

我能够成功地做到这一点。 即使我使用HTML格式,它发送HTML格式。

我想这一点。我知道映像应上传到服务器,但我会在稍后做。

  $正文部分='
<车身风格=背景色:#FFFFFF;>

< IMG ID =头的风格=的位置是:绝对的;左:85px;顶:50像素;SRC =图像/ logo.jpgWIDTH =140HEIGHT =90的边界=0ALT = />&所述; / a取代;


< IMG ID =布的风格=的位置是:绝对的;左:275px;顶:25像素; SRC =图像/ cloths.jpgWIDTH =350HEIGHT =300的边界=0ALT =/>< / A>

<字体大小=7的风格=字体家庭:宋体;位置:绝对的;左:50像素;顶:120px;>谢谢< / FONT>

<字体大小=3的风格=字体家庭:宋体;位置:绝对的;左:50像素;顶:165像素;>作为与我们的团队和LT注册; / FONT>

< IMG ID =袋的风格=的位置是:绝对的;左:290px;顶:345px;SRC =图像/ bag1.jpgWIDTH =250HEIGHT =240的边界=0ALT = />&所述; / a取代;

< IMG风格=的位置是:绝对的;左:30像素;顶:440px;ID =观看SRC =图像/ watch1.jpgWIDTH =260HEIGHT =180的边界=0ALT = />&所述; / a取代;

< /身体GT;

';

  $ M-> setMessageFromString($ plainTextBody,$正文部分);

  的print_r($会话> sendEmail($ M));
 

我应该得到这个输出

但我得到这个代替。

但问题是格式不正确完成,即使它在我的本地主机可以作为一个独立的文件。我试图用外部CSS,内部CSS和内联CSS。但它不工作。

CSS和HTML中发送电子邮件工作的任何例子是非常有益的。

在此先感谢。

解决方案

更新时间: 正如我认为,你刚才做副本paste.Try以下code。学习HTML基本语法。

  

别忘了upvote和放大器;标志作为回答;)

  $正文部分='

< BODY
!< D​​OCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
< HEAD>
< META HTTP-当量=Content-Type的CONTENT =text / html的;字符集= UTF-8/>
<冠军>无标题文档< /标题>
< /头>

<车身风格=的margin-top:20px的;>
<表格的宽度=600的cellpadding =0CELLSPACING =0ALIGN =中心>


&其中; TR>
  < TD>
    < IMG ID =头SRC =图像/ logo.jpgWIDTH =140HEIGHT =90的边界=0ALT =/>< / A>
  < / TD>
  < TD>
    < IMG ID =布SRC =图像/ cloths.jpgWIDTH =350HEIGHT =300的边界=0ALT =/>< / A>
  < / TD>
< / TR>

&其中; TR>
  < TD>
    <字体大小=7的风格=字体家庭:宋体;>谢谢< / FONT>
  < / TD>
  < TD>
    <字体大小=3的风格=字体家庭:宋体;>作为与我们的团队和LT注册; / FONT>
  < / TD>
< / TR>
&其中; TR>
  < TD>
    < IMG ID =袋SRC =图像/ bag1.jpgWIDTH =250HEIGHT =240的边界=0ALT =/>< / A>
  < / TD>
  < TD>
    < IMG ID =观看SRC =图像/ watch1.jpgWIDTH =260HEIGHT =180的边界=0ALT =/>< / A>
  < / TD>
  < / TR>
< /表>';

回声$正文部分;
 

前一封 使简单。把一个表在HTML身体放;固定的宽度。

您的电子邮件正文应像下面的

  $身体=<<< BODY
!< D​​OCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
< HEAD>
< META HTTP-当量=Content-Type的CONTENT =text / html的;字符集= UTF-8/>
<冠军>无标题文档< /标题>
< /头>

&所述;身体LEFTMARGIN =0rightmargin =0TOPMARGIN =0bottommargin =0MARGINWIDTH =0MARGINHEIGHT =0>
<表格的宽度=600的cellpadding =0CELLSPACING =0ALIGN =中心>
&其中; TR>
< TD> =============你的内容=========< / TD>
< / TR>
< /表>
体;

回声$的身体;
 

I am developing a website in php and want to send email to a user when user signs up.

I am able to do it successfully. Even i using html format and it's sending in html format.

I tried this. I know images should be uploaded to server but i will do it later.

$bodyPart = '
<body style="background-color:#FFFFFF;">

<img id="header" style="position:absolute; left:85px; top:50px; " src="images/logo.jpg" width="140" height="90" border="0" alt="" /></a>


<img id="cloths" style="position:absolute; left:275px; top:25px;" src="images/cloths.jpg" width="350" height="300" border="0" alt="" /></a>

<font size="7" style="font-family:Times new Roman; position:absolute; left:50px; top:120px;">Thank YOU</font>

<font size="3" style="font-family:Times new Roman;position:absolute;left:50px; top:165px;">For registering with our team </font>

<img id="bag" style ="position:absolute; left:290px; top:345px;"src="images/bag1.jpg" width="250" height="240" border="0" alt="" /></a>

<img style="position:absolute; left:30px; top:440px; "id="watch" src="images/watch1.jpg" width="260" height="180" border="0" alt="" /></a>

</body>

';

  $m->setMessageFromString($plainTextBody,$bodyPart);

  print_r($ses->sendEmail($m));

I should be getting this output

But i am getting this instead.

But the problem is formatting is not properly done even if it works in my localhost as a independent file. I tried to use External CSS, Internal CSS and inline CSS. But it's not working.

Any example of CSS working with html in sending email would be very helpful.

Thanks In advance.

解决方案

UPDATED As i assumed, you have just done copy paste.Try following code. Learn HTML basic syntax.

Don't forget to upvote & mark as answered ;)

$bodyPart = ' 

<BODY 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body style="margin-top:20px;"> 
<table width="600" cellpadding="0" cellspacing="0" align="center"> 


<tr> 
  <td> 
    <img id="header" src="images/logo.jpg" width="140" height="90" border="0" alt="" /></a> 
  </td>
  <td>
    <img id="cloths" src="images/cloths.jpg" width="350" height="300" border="0" alt="" /></a> 
  </td>
</tr>

<tr>
  <td>
    <font size="7" style="font-family:Times new Roman;">Thank YOU</font> 
  </td>
  <td>
    <font size="3" style="font-family:Times new Roman;">For registering with our team </font> 
  </td>
</tr>
<tr>
  <td>
    <img id="bag" src="images/bag1.jpg" width="250" height="240" border="0" alt="" /></a> 
  </td>
  <td>
    <img id="watch" src="images/watch1.jpg" width="260" height="180" border="0" alt="" /></a> 
  </td>
  </tr> 
</table>';

echo $bodyPart;

OLDER Make it simple. Put one table in your html body & fixed the width.

Your email body should be like following

$body = <<<BODY
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table width="600" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>=============Your content =========</td>
</tr>
</table>
BODY;

echo $body;

这篇关于CSS不工作的电子邮件发送使用AWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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