0

我有 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; 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();
4

2 回答 2

0

我认为您正在尝试发送 html,所以请尝试这样

   $mail->Body = $html;
   $mail->Send();

好的,所以您尝试发送它,但它不起作用?

  $mail->AddAttachment("/var/tmp/file.html");
于 2013-08-07T10:24:44.983 回答
0

AddAttachment()需要一个文件(在文件系统上)

AddStringAttachment()你正在做的事情的功能。见文档:http ://docs.redaxo.com/de/4.3.1/class_p_h_p_mailer.html#a92ef5134fdce5bd5fd24a723c508bf2b

试试这个:

$mail->AddStringAttachment($html,"filename.htm","base64","text/html");
于 2013-08-07T10:26:18.763 回答