本文整理汇总了PHP中Cake\Mailer\Email::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::getHeaders方法的具体用法?PHP Email::getHeaders怎么用?PHP Email::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Mailer\Email
的用法示例。
在下文中一共展示了Email::getHeaders方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send email via Mailgun SDK
*
* @param Email $email
* @return \stdClass $result containing status code and message
* @throws Exception
*/
public function send(Email $email)
{
$config = $email->profile();
$email->domain($config['mailgun_domain']);
$emailHeaders = ['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject', '_headers'];
//'_headers' will include all extra tags that may be related to mailgun fields with prefix 'o:' or custom data with prefix 'v:'
foreach ($email->getHeaders($emailHeaders) as $header => $value) {
if (isset($this->ParamMapping[$header]) && !empty($value)) {
//empty params are not excepted by mailgun, throws error
$key = $this->ParamMapping[$header];
$params[$key] = $value;
continue;
}
if ($this->isDataCustom($header, $value)) {
$params[$header] = $value;
}
}
$params['html'] = $email->message(Email::MESSAGE_HTML);
$params['text'] = $email->message(Email::MESSAGE_TEXT);
$attachments = array();
foreach ($email->attachments() as $name => $file) {
$attachments['attachment'][] = ['filePath' => '@' . $file['file'], 'remoteName' => $name];
}
return $this->mailgun($config, $params, $attachments);
}
示例2: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Cake Email
* @return array
*/
public function send(Email $email)
{
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']);
$headers = $this->_headersToString($headers);
$message = implode("\r\n", (array) $email->message());
return ['headers' => $headers, 'message' => $message];
}
示例3: send
public function send(Email $email)
{
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
$to = $headers['To'];
$subject = str_replace(["\r", "\n"], '', $email->subject());
$to = str_replace(["\r", "\n"], '', $to);
$message = implode('\\n', $email->message());
Log::write('debug', 'Mail: to(' . $to . ') subject(' . $subject . ') message(' . $message . ')');
return ['headers' => $headers, 'message' => $message];
}
示例4: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Email
* @return array
*/
public function send(Email $email)
{
if (!empty($this->_config['queue'])) {
$this->_config = $this->_config['queue'] + $this->_config;
$email->config((array) $this->_config['queue'] + ['queue' => []]);
unset($this->_config['queue']);
}
$settings = ['from' => [$email->from()], 'to' => [$email->to()], 'cc' => [$email->cc()], 'bcc' => [$email->bcc()], 'charset' => [$email->charset()], 'replyTo' => [$email->replyTo()], 'readReceipt' => [$email->readReceipt()], 'returnPath' => [$email->returnPath()], 'messageId' => [$email->messageId()], 'domain' => [$email->domain()], 'getHeaders' => [$email->getHeaders()], 'headerCharset' => [$email->headerCharset()], 'theme' => [$email->theme()], 'profile' => [$email->profile()], 'emailFormat' => [$email->emailFormat()], 'subject' => method_exists($email, 'getOriginalSubject') ? [$email->getOriginalSubject()] : [$email->subject()], 'transport' => [$this->_config['transport']], 'attachments' => [$email->attachments()], 'template' => $email->template(), 'viewVars' => [$email->viewVars()]];
foreach ($settings as $setting => $value) {
if (array_key_exists(0, $value) && ($value[0] === null || $value[0] === [])) {
unset($settings[$setting]);
}
}
$QueuedJobs = $this->getQueuedJobsModel();
$result = $QueuedJobs->createJob('Email', ['settings' => $settings]);
$result['headers'] = '';
$result['message'] = '';
return $result;
}
示例5: send
/**
* Send mail
*
* @param \Cake\Mailer\Email $email Cake Email
* @return array
*/
public function send(Email $email)
{
$eol = PHP_EOL;
if (isset($this->_config['eol'])) {
$eol = $this->_config['eol'];
}
$headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
$to = $headers['To'];
unset($headers['To']);
foreach ($headers as $key => $header) {
$headers[$key] = str_replace(["\r", "\n"], '', $header);
}
$headers = $this->_headersToString($headers, $eol);
$subject = str_replace(["\r", "\n"], '', $email->subject());
$to = str_replace(["\r", "\n"], '', $to);
$message = implode($eol, $email->message());
$params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
$this->_mail($to, $subject, $message, $headers, $params);
return ['headers' => $headers, 'message' => $message];
}
示例6: _prepareMessageHeaders
/**
* Prepares the message headers.
*
* @param \Cake\Mailer\Email $email Email instance
* @return array
*/
protected function _prepareMessageHeaders($email)
{
return $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'to', 'cc', 'subject', 'returnPath']);
}
示例7: testBodyEncodingIso2022JpMs
/**
* Tests that the body is encoded using the configured charset (Japanese irregular encoding, but sometime use this)
*
* @return void
*/
public function testBodyEncodingIso2022JpMs()
{
$email = new Email(['charset' => 'iso-2022-jp-ms', 'headerCharset' => 'iso-2022-jp-ms', 'transport' => 'debug']);
$email->subject('あれ?もしかしての前と');
$headers = $email->getHeaders(['subject']);
$expected = "?ISO-2022-JP?B?GyRCJCIkbCEpJGIkNyQrJDckRiROQTAkSBsoQg==?=";
$this->assertContains($expected, $headers['Subject']);
$email->to('someone@example.com')->from('someone@example.com');
$result = $email->send('①㈱');
$this->assertTextContains("Content-Type: text/plain; charset=ISO-2022-JP", $result['headers']);
$this->assertTextNotContains("Content-Type: text/plain; charset=iso-2022-jp-ms", $result['headers']);
// not charset=iso-2022-jp-ms
$this->assertContains(mb_convert_encoding('①㈱', 'ISO-2022-JP-MS'), $result['message']);
}