【发布时间】:2015-09-09 08:18:25
【问题描述】:
我正在尝试完成发送带有附件的邮件
问题:发送的电子邮件没有邮件正文和附件
目标:发送utf-8html带附件的电子邮件
到目前为止我已经创建...
用法:
email_library.php
<?php
private function create_body()
{
$this->body[] = "--{$this->uid}";
$this->body[] = "Content-type: text/html; charset=utf-8";
$this->body[] = "Content-Transfer-Encoding: 7bit";
$this->body[] = $this->message;
if (!empty($this->attachments)) {
foreach ($this->attachments as $k => $a) {
$this->body[] = "--{$this->uid}";
$this->body[] = "Content-Type: application/octet-stream; name=\"{$a['name']}\"";
$this->body[] = "Content-Description: {$a['name']}";
$this->body[] = "Content-Transfer-Encoding: base64";
$this->body[] = "Content-Disposition: attachment; filename=\"{$a['name']}\"";
$this->body[] = "{$a['data']}";
}
}
$this->body[] = "--{$this->uid}--";
}
编辑:
$this->body[] = "--{$this->uid}";
删除"--"
最后一个正文部分之后的封装边界是一个可区分的分隔符,表示后面不会有其他正文部分。
【问题讨论】:
-
乍一看,您的脚本在我看来还不错...您是否尝试过发送不带附件的电子邮件?
标签: php email attachment