附加文件时电子邮件正文中的空白间距问题

时间:2017-10-09 06:06:43

标签: php csv email drupal-7

我发送HTML php电子邮件文件csv附件。

它工作正常,但问题是它在邮件正文中的字母之间需要空白。

这是我的电子邮件代码

 $mailHader = '<div class="image" style="width:100%;margin-top: 20px;"><p style="text-align: center;"><a target="_blank" href="https://www.example.com"><span style="text-decoration:none"><img border="0" height="175" width="174" style="margin:0 auto; height: 80px; width: 80px;" alt="" src="https://www.example.com/sites/default/files/logo.png"></span></a></p></div></br>';

       $body= $mailHader."<table width='100%' bgcolor='#fff' border='0' cellpadding='20' cellspacing='0'> <tr> <td> <table class='content' align='center' cellpadding='0' cellspacing='0' border='0' style='margin-bottom:20px;width:100%;'> <tr> <td><p style='margin-bottom:20px;'>Dear Admin,</p><p style='margin-bottom:20px;'>Here are the membership report for users</p><p style='margin-bottom:20px;'>Please find the attached csv file.</p></td></tr></table><table class='content' align='center' cellpadding='0' cellspacing='0' border='0' style='width:100%;'> <tr> <td><p style='margin-bottom:20px;margin-top:20px;'>All the best,</p></td></tr></table> </td></tr></table>";  

send_csv_mail($body,$to,$from);

function send_csv_mail($body,$to,$from) {

    $subject = 'Report';
        // This will provide plenty adequate entropy
        $multipartSep = '-----'.md5(time()).'-----';

        // Arrays are much more readable
        $headers = array(
            "From: $from",
            "Reply-To: $from",
           "Content-Type: multipart/mixed; boundary=$multipartSep"
        );

        // Make the attachment
        $attachment = chunk_split(base64_encode(create_csv_string())); 

        // Make the body of the message
        $body = "--$multipartSep\r\n"
            . "Content-Type: text/html; charset=ISO-8859-1;\r\n"
            . "Content-Transfer-Encoding: 7bit\r\n"
            . "\r\n"
            . "$body\r\n"
            . "--$multipartSep\r\n"
            . "Content-Type: text/csv\r\n"
            . "Content-Transfer-Encoding: base64\r\n"
            . "Content-Disposition: attachment; filename=Website-Report-" . date("F-j-Y") . ".csv\r\n"
            . "\r\n"
            . "$attachment\r\n"
            . "--$multipartSep--";


        // Send the email, return the result
        return @mail($to, $subject, $body, implode("\r\n", $headers));

}

    function create_csv_string() {
    // my custom function to generate csv file
    }

它发送电子邮件给我

亲爱的管理员, 以下是用户的会员报告 请找到附加的csv文件。

所有是st

它在字母之间创建间距(如st,fi等)

任何想法?

0 个答案:

没有答案