本文整理匯總了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;
}