通过phpmailer将html作为附件发送
我有html变量,我想通过电子邮件将其作为附件发送 这是我的密码通过phpmailer将html作为附件发送,php,html,email,phpmailer,Php,Html,Email,Phpmailer,我有html变量,我想通过电子邮件将其作为附件发送 这是我的密码 $html=' <table cellpadding="0" cellspacing="0" style=" margin:0 auto;" width="100%"> <tr> <th style="background:#FC3; padding:4px 0;border:1px solid #000; border-bottom:2px solid #000; bord
$html='
<table cellpadding="0" cellspacing="0" style=" margin:0 auto;" width="100%">
<tr>
<th style="background:#FC3; padding:4px 0;border:1px solid #000; border-bottom:2px solid #000; border-right:2px solid #000;" align="center" valign="middle"><h3 style="font:300 14px verdana; margin:0; text-align:left;text-align:center;">DECLARATION BY THE AGENT</h3></th>
<th style="background:#FC3; padding:4px 0;border:1px solid #000; border-bottom:2px solid #000; border-right:2px solid #000;" align="center" valign="middle"><h3 style="font:300 14px verdana; margin:0; text-align:left;text-align:center;">DECLARATION BY THE OWNER (The Seller)</h3></th>
</tr>
<tr>
<td width="49%" style="padding:5px 10px;border-right:2px solid #000;">
<ul style="margin:0; padding:0;">
<li style="list-style:none; margin:0 0 10px 0;">
<p style="font:300 12px verdana;float: left; margin:0 5px 0 0;text-align:center;">
I hereby declare, I have read and understood the Real Estate Brokers Code of Ethics,
</p>
</li>
</ul></td>
<td width="49%" style="padding:5px 10px;border-left:1px solid #000;">
<ul style="margin:0; padding:0;">
<li style="list-style:none; margin:0 0 10px 0;">
<p style="font:300 12px verdana;float: left; margin:0 5px 0 0; text-align:center;">
I/We hereby declare, we are the Owners of the property as stated below.
</p>
</li>
</ul></td>
</tr>
</table>';
$mail->AddAttachment($html); // attachment
$mail->Send();
$html='1!'
代理声明
业主(卖方)声明
-
本人特此声明,本人已阅读并理解《房地产经纪人道德规范》,
-
我/我们特此声明,我们是下述财产的所有人。
';
$mail->AddAttachment($html);//附件
$mail->Send();
我想您是在尝试发送html,所以请这样尝试
$mail->Body = $html;
$mail->Send();
好的,比如说,你试图发送它,但它不起作用
$mail->AddAttachment("/var/tmp/file.html");
AddAttachment()
需要一个文件(在文件系统上)
有一个AddStringAttachment()
函数用于您正在做的事情。见文件:
试试这个:
$mail->AddStringAttachment($html,"filename.htm","base64","text/html");
这只是一个例子。我有一个完整的html表单/页面。我想把它发送给客户,这样他就可以下载并填写表单。基本上,我想把这个html表单发送给客户,这样他就可以下载并填写表单。你试过了吗?它应该将
filename.htm
和$html
中的html代码作为附件添加到电子邮件中。这就是你想要的,不是吗?是的,它可以工作,但当我们下载它时,图像丢失了…有没有其他方法可以让我发送此表单?当然图像丢失了,你不发送它们!只需使用绝对url链接图像。使用src=”http://www.yourdomain.com/img.jpg“
而不是src=“img.jpg”
我们可以将其与其他类型(如filename.pdf或filename.csv等)一起发送吗?