本文整理汇总了PHP中Zend\Mail\Message::addCc方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::addCc方法的具体用法?PHP Message::addCc怎么用?PHP Message::addCc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::addCc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromWrappedMessage
/**
* @inheritDoc
*/
public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
{
if (!$wrappedMessage instanceof MailWrappedMessage) {
throw new MailWrapperSetupException('Not MailWrappedMessage');
}
$message = new Message();
foreach ($wrappedMessage->getToRecipients() as $address) {
$message->addTo($address);
}
foreach ($wrappedMessage->getCcRecipients() as $address) {
$message->addCc($address);
}
foreach ($wrappedMessage->getBccRecipients() as $address) {
$message->addBcc($address);
}
$message->setReplyTo($wrappedMessage->getReplyTo());
$message->setFrom($wrappedMessage->getFrom());
$message->setSubject($wrappedMessage->getSubject());
if ($wrappedMessage->getContentText()) {
$message->setBody($wrappedMessage->getContentText());
}
if ($wrappedMessage->getContentHtml()) {
$html = new MimePart($wrappedMessage->getContentHtml());
$html->type = "text/html";
$message->setBody($body);
}
return $message;
}
示例2: testRestoreFromSerializedString
public function testRestoreFromSerializedString()
{
$this->message->addTo('zf-devteam@example.com', 'ZF DevTeam');
$this->message->addFrom('matthew@example.com', "Matthew Weier O'Phinney");
$this->message->addCc('zf-contributors@example.com', 'ZF Contributors List');
$this->message->setSubject('This is a subject');
$this->message->setBody('foo');
$serialized = $this->message->toString();
$restoredMessage = Message::fromString($serialized);
$this->assertEquals($serialized, $restoredMessage->toString());
}
示例3: sendMail
public function sendMail($mailOptions = array())
{
$this->_setMailOptions($mailOptions);
$text = new Part($this->mailBody);
$text->type = Mime::TYPE_HTML;
$mailBodyParts = new MimeMessage();
$mailBodyParts->addPart($text);
if (!empty($this->fileNames) && !empty($this->filePaths)) {
foreach ($this->filePaths as $key => $filePath) {
$file = new Part(file_get_contents($filePath));
$file->encoding = Mime::ENCODING_BASE64;
$file->type = finfo_file(finfo_open(), $filePath, FILEINFO_MIME_TYPE);
$file->disposition = Mime::DISPOSITION_ATTACHMENT;
$file->filename = $this->fileNames[$key];
$mailBodyParts->addPart($file);
}
}
$options = array();
if ($this->useSMTP === false) {
$options = new SmtpOptions(array("name" => $this->smtpName, "host" => $this->smtpHost, "port" => $this->smtpPort));
} else {
$options = new SmtpOptions(array('name' => $this->smtpName, 'host' => $this->smtpHost, 'port' => $this->smtpPort, 'connection_class' => $this->smtpConnectionClass, 'connection_config' => array('ssl' => $this->smtpSsl, 'username' => $this->smtpUsername, 'password' => $this->smtpPassword)));
}
$mail = new Message();
$mail->setBody($mailBodyParts);
$mail->setFrom($this->mailFrom, $this->mailFromNickName);
$mail->addTo($this->mailTo);
if (!empty($this->mailCc)) {
$mail->addCc($this->mailCc);
}
if (!empty($this->mailBcc)) {
$mail->addBcc($this->mailBcc);
}
$mail->setSubject($this->mailSubject);
$transport = new SmtpTransport();
$transport->setOptions($options);
$emailLogInfo = array('email_to' => $this->mailTo, 'email_from' => $this->mailFrom, 'email_body' => $this->mailBody, 'email_subject' => $this->mailSubject, 'sender_type' => $this->mailSenderType);
$emailSend = 0;
try {
$transport->send($mail);
$emailSend = 1;
} catch (\Exception $e) {
$emailLogInfo['email_error'] = $e->getMessage();
throw $e;
}
return $emailSend;
}
示例4: execute
/**
* Send email
*
* @access public
*/
public function execute()
{
$payload = $this->getContent();
$from = $payload['from'];
$to = $payload['to'];
$subject = $payload['subject'];
$body = $payload['body'];
$message = new Message();
$message->addTo($to)->addFrom($from)->setSubject($subject)->setBody($body);
if (array_key_exists('bcc', $payload)) {
$bcc = $payload['bcc'];
$message->addBcc($bcc);
}
if (array_key_exists('cc', $payload)) {
$cc = $payload['cc'];
$message->addCc($cc);
}
$this->transport->send($message);
}
示例5: sendMail
public function sendMail($mail)
{
// Build the message body
$mimeParts = array();
foreach ($mail->getParts() as $part) {
$mimePart = new MimePart($part->getContent());
$mimePart->type = $part->getType();
$mimeParts[] = $mimePart;
}
$body = new MimeMessage();
$body->setParts($mimeParts);
// Build the message.
$message = new Mail\Message();
$message->setBody($body);
// Set the participants
foreach ($mail->getParticipants() as $participant) {
if ($participant->getComposition() == 'to') {
$message->addTo($participant->getAddress(), $participant->getName());
}
if ($participant->getComposition() == 'cc') {
$message->addCc($participant->getAddress(), $participant->getName());
}
if ($participant->getComposition() == 'bcc') {
$message->addBcc($participant->getAddress(), $participant->getName());
}
if ($participant->getComposition() == 'from') {
$message->addFrom($participant->getAddress(), $participant->getName());
}
}
// Set the subject
$message->setSubject($mail->getSubject());
$contentType = $mail->getContentType();
if ($contentType) {
$message->getHeaders()->get('content-type')->setType($contentType);
}
// Create the transport and send.
$transport = new SmtpTransport();
$transport->setOptions(new SmtpOptions($this->options));
$transport->send($message);
}
示例6: attachDefaultListeners
public function attachDefaultListeners()
{
if ($this->eventManager !== null) {
return;
}
$this->getEventManager()->attach(self::EVENT_SEND_MAIL, function (EventInterface $e) {
$params = $e->getParams();
$message = new Message();
$attachments = [];
if (isset($params['to']) && is_array($params['to'])) {
$message->setTo($params['to']['email'], $params['to']['name']);
}
if (isset($params['cc']) && is_array($params['cc'])) {
foreach ($params['cc'] as $cc) {
$message->addCc($cc['email'], $cc['name']);
}
}
if (isset($params['bcc']) && is_array($params['bcc'])) {
foreach ($params['bcc'] as $bcc) {
$message->addBcc($bcc['email'], $bcc['name']);
}
}
if (isset($params['from']) && is_array($params['from'])) {
$message->setFrom($params['from']['email'], $params['from']['name']);
}
if (isset($params['subject']) && $params['subject']) {
$message->setSubject($params['subject']);
}
if (isset($params['body']) && $params['body']) {
$message->setBody($params['body']);
}
if (isset($params['attachments']) && is_array($params['attachments'])) {
foreach ($params['attachments'] as $filePath) {
$attachments[] = $this->getPartFromFile($filePath);
}
}
$this->send($message, $attachments);
});
}
示例7: setShadowRecipients
/**
* Set the BCC and CC recipients to the email (they are the same for every email).
*
* @return Message
*/
public function setShadowRecipients()
{
//Cc recipients
foreach ($this->email->getCc() as $emailAddress => $contact) {
if ($contact instanceof Contact) {
$this->message->addCc($contact->getEmail(), $contact);
} else {
$this->message->addCc($emailAddress, $contact);
}
}
//Bcc recipients
foreach ($this->email->getBcc() as $emailAddress => $contact) {
if ($contact instanceof Contact) {
$this->message->addBcc($contact->getEmail(), $contact);
} else {
$this->message->addBcc($emailAddress, $contact);
}
}
if (!is_null($this->email->getReplyTo())) {
$this->message->addReplyTo($this->email->getReplyTo(), $this->email->getReplyToName());
}
}
示例8: send
public function send($data = array(), $viewModel)
{
if ($viewModel instanceof ModelInterface) {
$body = $this->renderModel($viewModel);
} elseif (is_string($viewModel)) {
$body = $this->renderText($viewModel);
} else {
throw new \Exception('Invalid viewModel for mail body');
}
$text = new MimePart('');
$text->type = "text/plain";
$html = new MimePart($body);
$html->type = "text/html";
$body_html = new MimeMessage();
$body_html->setParts(array($text, $html));
$mail = new Mail\Message();
$mail->setEncoding("UTF-8");
$mail->setBody($body_html);
$mail->setFrom($this->_from_mail, $this->_from_name);
$mail->addTo($data['to']);
if (isset($data['cc'])) {
$mail->addCc($data['cc']);
}
if (isset($data['bcc'])) {
$mail->addBcc($data['bcc']);
}
if (isset($data['replyTo'])) {
$mail->addReplyTo($data['replyTo'], $data['replyNameTo']);
} else {
$mail->addReplyTo($this->_from_mail, $this->_from_name);
}
if (isset($data['dkimSign'])) {
$signer = $this->getController()->getServiceLocator()->get('DkimSigner');
$signer->signMessage($mail);
}
$mail->setSubject($data['subject']);
return $this->_transport->send($mail);
}
示例9: getMessage
/**
* @param UserInterface $user
* @return Message
*/
protected function getMessage(UserInterface $user)
{
// Emailing logic here
$content = $this->renderMessageContent($user);
$htmlPart = new MimePart($content);
$htmlPart->type = "text/html";
$textPart = new MimePart($content);
$textPart->type = "text/plain";
$body = new MimeMessage();
$body->setParts(array($textPart, $htmlPart));
$message = new Message();
$message->addFrom($this->getOptions()->get('from_email'), $this->getOptions()->get('from_name'));
$message->addTo($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName());
$ccs = $this->getOptions()->get('copy_to', array());
foreach ($ccs as $cc) {
$message->addCc($cc);
}
$message->setSubject($this->getOptions()->get('reset_subject', 'Please Reset Your Password'));
$message->setEncoding("UTF-8");
$message->setBody($body);
$message->getHeaders()->get('content-type')->setType('multipart/alternative');
return $message;
}
示例10: testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders
public function testSettingNonAsciiEncodingForcesMimeEncodingOfSomeHeaders()
{
$this->message->addTo('zf-devteam@zend.com', 'ZF DevTeam');
$this->message->addFrom('matthew@zend.com', "Matthew Weier O'Phinney");
$this->message->addCc('zf-contributors@lists.zend.com', 'ZF Contributors List');
$this->message->addBcc('zf-crteam@lists.zend.com', 'ZF CR Team');
$this->message->setSubject('This is a subject');
$this->message->setEncoding('UTF-8');
$test = $this->message->getHeaders()->toString();
$expected = '=?UTF-8?Q?ZF=20DevTeam?=';
$this->assertContains($expected, $test);
$this->assertContains('<zf-devteam@zend.com>', $test);
$expected = "=?UTF-8?Q?Matthew=20Weier=20O'Phinney?=";
$this->assertContains($expected, $test, $test);
$this->assertContains('<matthew@zend.com>', $test);
$expected = '=?UTF-8?Q?ZF=20Contributors=20List?=';
$this->assertContains($expected, $test);
$this->assertContains('<zf-contributors@lists.zend.com>', $test);
$expected = '=?UTF-8?Q?ZF=20CR=20Team?=';
$this->assertContains($expected, $test);
$this->assertContains('<zf-crteam@lists.zend.com>', $test);
$expected = 'Subject: =?UTF-8?Q?This=20is=20a=20subject?=';
$this->assertContains($expected, $test);
}
示例11: sendemail
//.........这里部分代码省略.........
default:
break;
}
$options = new SmtpOptions($smtp_args);
$transport->setOptions($options);
$message = new Message();
$message->addFrom($fromemail, $fromname);
if (!empty($email)) {
$message_id = $reference_id = $in_reply_to = '';
if ('comment' == $email->refrence_type) {
$message_id = get_comment_meta($email->refrence_id, '_rtlib_messageid', true);
$reference_id = get_comment_meta($email->refrence_id, '_rtlib_references', true);
if (empty($message_id)) {
$comment = get_comment($email->refrence_id);
$post_id = $comment->comment_post_ID;
}
} else {
if ('post' == $email->refrence_type) {
$post_id = $email->refrence_id;
}
}
if (isset($post_id)) {
$reference_id = get_post_meta($post_id, '_rtlib_references', true);
$message_id = rtmb_get_reply_to_from_ref_id($reference_id);
$reply_to = apply_filters('rtlib_reply_to_header', '', $fromemail, $post_id);
if (!empty($reply_to)) {
$message->addCustomeHeader('Reply-To', trim($reply_to));
}
}
//Get reply to header
if (!empty($message_id)) {
$message->addCustomeHeader('In-Reply-To', trim($message_id));
}
//Get References header
if (!empty($message_id)) {
$reference_id = rtmb_add_message_id_in_ref_id($message_id, $reference_id);
}
if (!empty($reference_id)) {
$reference_ids = rtmb_get_reference_id_array($reference_id);
$_reference_id = implode(' ', $reference_ids);
$message->addCustomeHeader('References', $_reference_id);
}
// Add x-mailer
if (!empty($email->refrence_id)) {
$message->addCustomeHeader('X-Mailer', 'rtCamp-mail-lib');
if ('comment' == $email->refrence_type) {
$comment = get_comment($email->refrence_id);
$post_id = $comment->comment_post_ID;
} else {
$post_id = $email->refrence_id;
}
$new_message_id = rtmb_generate_message_id($post_id, $email->id);
rtmb_add_message_id_in_ref_id($new_message_id, $reference_id, $post_id);
$message->addCustomeHeader('Message-ID', $new_message_id);
}
}
//$mail->setFrom($fromemail);
$message->setSubject(stripslashes_deep(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')));
//$mail->setSubject($subject);
if (!empty($toEmail)) {
foreach ($toEmail as $temail) {
//$mail->addTo($temail["email"], isset($temail["name"]) ? $temail["name"] : '');
$message->addTo($temail['email'], isset($temail['name']) ? $temail['name'] : '');
}
}
if (!empty($ccEmail)) {
foreach ($ccEmail as $temail) {
//$mail->addCc($temail["email"], isset($temail["name"]) ? $temail["name"] : '');
$message->addCc($temail['email'], isset($temail['name']) ? $temail['name'] : '');
}
}
if (!empty($bccEmail)) {
foreach ($bccEmail as $temail) {
if (isset($temail['email'])) {
$message->addBcc($temail['email'], isset($temail['name']) ? $temail['name'] : '');
}
}
}
// create a MimeMessage object that will hold the mail body and any attachments
$bodyPart = new MimeMessage();
$bodyMessage = new MimePart($body);
$bodyMessage->type = 'text/html';
$bodyMessage->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$bodyPart->addPart($bodyMessage);
if (!empty($attachemnts) && is_array($attachemnts)) {
foreach ($attachemnts as $attach) {
$file_array = explode('/', $attach);
$fileName = $file_array[count($file_array) - 1];
$attachment = new MimePart(file_get_contents($attach));
$attachment->type = rtmb_get_mime_type($attach);
$attachment->filename = $fileName;
$attachment->encoding = Zend\Mime\Mime::ENCODING_BASE64;
$attachment->disposition = Zend\Mime\Mime::DISPOSITION_ATTACHMENT;
$bodyPart->addPart($attachment);
}
}
$message->setBody($bodyPart);
$transport->send($message);
return true;
}
示例12: testMsgHandleUidSearch
//.........这里部分代码省略.........
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('steve@apple.com');
$message->setSubject('my_subject 17');
$message->setBody('my_body');
$server->addMail($message, null, array(), false);
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('dev2@fox21.at');
$message->setSubject('my_subject 18');
$message->setBody('my_body');
$server->addMail($message, null, array(), false);
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('dev2@fox21.at');
$message->setSubject('my_subject 19');
$message->setBody('my_body');
$server->addMail($message, null, array(Storage::FLAG_ANSWERED), false);
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('dev2@fox21.at');
$message->setSubject('my_subject 20');
$message->setBody('my_body');
$server->addMail($message, null, array(Storage::FLAG_DELETED), false);
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('dev2@fox21.at');
$message->setSubject('my_subject 21');
$message->setBody('my_body');
$server->addMail($message, null, array(Storage::FLAG_DRAFT), false);
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('dev2@fox21.at');
$message->addCc('dev3@fox21.at');
$message->setSubject('my_subject 22');
$message->setBody('my_body');
$server->addMail($message, null, array(Storage::FLAG_FLAGGED), false);
$message = new Message();
$message->addFrom('dev1@fox21.at');
$message->addTo('dev2@fox21.at');
$message->addCc('dev3@fox21.at');
$message->setSubject('my_subject 23');
$message->setBody('my_body');
$server->addMail($message, null, array(Storage::FLAG_SEEN), false);
$msg = $client->msgHandle('17 uid SEARCH');
$expect = '17 BAD Arguments invalid.' . Client::MSG_SEPARATOR;
$this->assertEquals($expect, $msg);
$msg = $client->msgHandle('17 uid SEARCH ALL');
$expect = '* SEARCH 100001 100002 100003 100004 100005 100006 100007 100008 100009 100010 ';
$expect .= '100011 100012 100013 100014 100015 100016 100017 100018 100019 100020 100021 ';
$expect .= '100022 100023' . Client::MSG_SEPARATOR;
$expect .= '17 OK UID SEARCH completed' . Client::MSG_SEPARATOR;
$this->assertEquals($expect, $msg);
$msg = $client->msgHandle('17 uid SEARCH ANSWERED');
$expect = '* SEARCH 100002 100019' . Client::MSG_SEPARATOR . '17 OK UID SEARCH completed' . Client::MSG_SEPARATOR;
$this->assertEquals($expect, $msg);
$msg = $client->msgHandle('17 uid SEARCH BCC apple');
$expect = '* SEARCH 100003' . Client::MSG_SEPARATOR . '17 OK UID SEARCH completed' . Client::MSG_SEPARATOR;
$this->assertEquals($expect, $msg);
#$msg = $client->msgHandle('17 uid SEARCH BEFORE 1990');
$expect = '* SEARCH 100004 100005' . Client::MSG_SEPARATOR . '17 OK UID SEARCH completed' . Client::MSG_SEPARATOR;
#$this->assertEquals($expect, $msg);
$msg = $client->msgHandle('17 uid SEARCH BODY world');
$expect = '* SEARCH 100006' . Client::MSG_SEPARATOR . '17 OK UID SEARCH completed' . Client::MSG_SEPARATOR;
$this->assertEquals($expect, $msg);
$msg = $client->msgHandle('17 uid SEARCH CC dev3');
示例13: sendMail
/**
* common functionality for send email
*
* @param array $mailOptions
* use mailTo,mailFrom,mailFromNickName,mailSubject,mailBody,...
* as options
* @author Kaushal
* @method sendMail
* @return int
*/
public function sendMail($mailOptions = array())
{
$config = $this->serviceManager->get('config');
$smtpName = $config['settings']['EMAIL']['SMTP_NAME'];
$smtpHost = $config['settings']['EMAIL']['SMTP_HOST'];
$smtpPort = $config['settings']['EMAIL']['SMTP_PORT'];
$smtpConnectionClass = $config['settings']['EMAIL']['SMTP_CONNECTION_CLASS'];
$smtpUsername = $config['settings']['EMAIL']['SMTP_USERNAME'];
$smtpPassword = $config['settings']['EMAIL']['SMTP_PASSWORD'];
$smtpSsl = $config['settings']['EMAIL']['SMTP_SSL'];
$mailBody = $config['settings']['EMAIL']['BODY'];
$mailFrom = $config['settings']['EMAIL']['FROM'];
$mailSubject = $config['settings']['EMAIL']['SUBJECT'];
$mailFromNickName = $config['settings']['EMAIL']['FROM_NICK_NAME'];
$mailTo = $config['settings']['EMAIL']['TO'];
$mailSenderType = $config['settings']['EMAIL']['SMTP_SENDER_TYPE'];
if (array_key_exists('mailTo', $mailOptions)) {
$mailTo = $mailOptions['mailTo'];
}
if (array_key_exists('mailCc', $mailOptions)) {
$mailCc = $mailOptions['mailCc'];
}
if (array_key_exists('mailFrom', $mailOptions)) {
$mailFrom = $mailOptions['mailFrom'];
}
if (array_key_exists('mailFromNickName', $mailOptions)) {
$mailFromNickName = $mailOptions['mailFromNickName'];
}
if (array_key_exists('mailSubject', $mailOptions)) {
$mailSubject = $mailOptions['mailSubject'];
}
if (array_key_exists('mailBody', $mailOptions)) {
$mailBody = $mailOptions['mailBody'];
}
if (array_key_exists('sender_type', $mailOptions)) {
$mailSenderType = $mailOptions['sender_type'];
}
$text = new Part($mailBody);
$text->type = \Zend\Mime\Mime::TYPE_HTML;
$mailBodyParts = new Message();
$mailBodyParts->addPart($text);
if (!empty($mailOptions['realFileName']) && !empty($mailOptions['tempFilePath'])) {
$file = new Part(file_get_contents($mailOptions['tempFilePath']));
$file->encoding = \Zend\Mime\Mime::ENCODING_BASE64;
$file->type = finfo_file(finfo_open(), $mailOptions['tempFilePath'], FILEINFO_MIME_TYPE);
$file->disposition = \Zend\Mime\Mime::DISPOSITION_ATTACHMENT;
// $file->filename =basename($mailOptions['tempFilePath']);
$file->filename = $mailOptions['realFileName'];
$mailBodyParts->addPart($file);
}
$options = new SmtpOptions(array("name" => $smtpName, "host" => $smtpHost, "port" => $smtpPort));
$mail = new Mail\Message();
$mail->setBody($mailBodyParts);
$mail->setFrom($mailFrom, $mailFromNickName);
$mail->addTo($mailTo);
if (!empty($mailCc)) {
$mail->addCc($mailCc);
}
$mail->setSubject($mailSubject);
$transport = new SmtpTransport();
$transport->setOptions($options);
$emailLogInfo = array('email_to' => $mailTo, 'email_from' => $mailFrom, 'email_body' => $mailBody, 'email_subject' => $mailSubject, 'sender_type' => $mailSenderType);
try {
/*
* Following line is commented temporary Uncomment while going
*/
$transport->send($mail);
$emailSend = 1;
} catch (\Exception $e) {
$emailSend = 0;
$emailLogInfo['email_error'] = $e->getMessage();
// print_r($emailLogInfo);
throw $e;
}
return $emailSend;
/*
* $emailLogInfo['email_send'] = ($emailSend == 1) ? 'y' : 'n'; if (is_array($mailTo)) { foreach ($mailTo as $value) { $emailLogInfo['email_to'] = $value; $emailSave = $this->saveEmailLog($emailLogInfo, $this->getServiceLocator()); } } else { $emailSave = $this->saveEmailLog($emailLogInfo, $this->getServiceLocator()); } $flag = ($emailSave == 1 && $emailSend == 1) ? 1 : 0; return $flag;
*/
}
示例14: setCc
function setCc($address)
{
foreach ((array) $address as $cc) {
$this->mail->addCc($cc);
}
}
示例15: sendEmail
public function sendEmail($template = 'message', $emailOptions = array())
{
$emailOptions = array_merge($this->config, $emailOptions);
$content = $this->renderEmail($template, $emailOptions);
if ($emailOptions['debug']) {
$displays = array();
foreach ($emailOptions as $key => $value) {
if ($key !== 'message' && $key != 'attachments') {
if (!is_object($value)) {
$displays[] = $key . ': <strong>' . (is_array($value) ? implode(',', $value) : $value) . '</strong>';
} else {
$displays[] = $key . ': <strong>OBJ</strong>';
}
}
}
echo '<div style="
background-color: #444;
padding: 50px;
box-shadow: 1px 1px 10px rgba(0,0,0,0.8) inset;
">
<div style="
width:80%;
margin:10px auto;
background-color:#ffffff;
box-shadow:1px 2px 5px rgba(0,0,0,0.5);
padding: 15px;
" >
' . implode(' ; ', $displays) . '
</div>
<div style="
width:80%;
margin:10px auto;
background-color:#ffffff;
box-shadow:1px 2px 5px rgba(0,0,0,0.5);
" >' . $content . '</div>' . (isset($emailOptions['attachments']) && $emailOptions['attachments'] ? '<div style="
width:80%;
margin:10px auto;
background-color:#ffffff;
box-shadow:1px 2px 5px rgba(0,0,0,0.5);
padding: 15px;
" >Mit Anhang</div>' : '') . '</div>';
}
$attachments = isset($emailOptions['attachments']) && $emailOptions['attachments'] && is_array($emailOptions['attachments']) ? $emailOptions['attachments'] : array();
$message = new Message();
$message->addTo($emailOptions['to']);
$message->addFrom($emailOptions['from']);
$message->setSubject($emailOptions['subject']);
if ($emailOptions['bcc']) {
$message->addBcc($emailOptions['bcc']);
}
if ($emailOptions['cc']) {
$message->addCc($emailOptions['cc']);
}
if ($this->html) {
// HTML part
$htmlPart = new MimePart($content);
$htmlPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$htmlPart->type = "text/html; charset=UTF-8";
}
// Plain text part
$textPart = new MimePart(strip_tags($content));
$textPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
$textPart->type = "text/plain; charset=UTF-8";
$body = new MimeMessage();
if ($attachments) {
// With attachments, we need a multipart/related email. First part
// is itself a multipart/alternative message
$content = new MimeMessage();
$content->addPart($textPart);
if ($this->html) {
$content->addPart($htmlPart);
}
$contentPart = new MimePart($content->generateMessage());
$contentPart->type = "multipart/alternative;\n boundary=\"" . $content->getMime()->boundary() . '"';
$body->addPart($contentPart);
$messageType = 'multipart/related';
// Add each attachment
foreach ($attachments as $thisAttachment) {
$attachment = new MimePart($thisAttachment['buffer']);
$attachment->filename = $thisAttachment['filename'];
$attachment->type = Mime::TYPE_OCTETSTREAM;
$attachment->encoding = Mime::ENCODING_BASE64;
$attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
$body->addPart($attachment);
}
} else {
// No attachments, just add the two textual parts to the body
if ($this->html) {
$body->setParts(array($textPart, $htmlPart));
$messageType = 'multipart/alternative';
} else {
$body->setParts(array($textPart));
$messageType = 'text/plain';
}
}
// attach the body to the message and set the content-type
$message->setBody($body);
$message->getHeaders()->get('content-type')->setType($messageType);
$message->setEncoding('UTF-8');
if ($emailOptions['send']) {
//.........这里部分代码省略.........