本文整理汇总了PHP中Part::setEncoded方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::setEncoded方法的具体用法?PHP Part::setEncoded怎么用?PHP Part::setEncoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::setEncoded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromData
public static function fromData($attachments = [], $content = '', $html = false)
{
$mail = new Mail();
$mail->charset = 'UTF-8';
$mail->contenttype = $html ? 'text/html' : 'text/plain';
$mail->encoding = 'quoted-printable';
$mail->text = $html ? null : $mail;
$mail->html = $html ? $mail : null;
$mail->setEncoded($html ? trim($content) : rtrim($content));
if ($attachments) {
$mail_multi = new Mail();
$mail_multi->boundary = uniqid('', true);
$mail_multi->contenttype = 'multipart/mixed';
$mail_multi->text = $mail->text;
$mail_multi->html = $mail->html;
foreach ($attachments as $attach) {
list($filename, $contenttype, $content) = $attach;
$mail_attach = new Part();
if (strpos($contenttype, 'text/') === 0) {
$mail_attach->charset = 'UTF-8';
$mail_attach->encoding = 'quoted-printable';
} else {
$contenttype == '' and $contenttype = 'application/octet-stream';
$mail_attach->encoding = 'base64';
}
$mail_attach->contenttype = $contenttype;
$mail_attach->disposition = 'attachment';
$mail_attach->filename = $filename;
$mail_attach->setEncoded($content);
$mail_multi->attachments[] = $mail_attach;
}
$mail = $mail_multi;
}
return $mail;
}