本文整理汇总了PHP中Cake\Network\Email\Email::message方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::message方法的具体用法?PHP Email::message怎么用?PHP Email::message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Network\Email\Email
的用法示例。
在下文中一共展示了Email::message方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send mail using Mandrill (by MailChimp)
*
* @param \Cake\Network\Email\Email $email Cake Email
* @return array
*/
public function send(Email $email)
{
$this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
// Initiate a new Mandrill Message parameter array
$message = ['html' => $email->message(\Cake\Network\Email\Email::MESSAGE_HTML), 'text' => $email->message(\Cake\Network\Email\Email::MESSAGE_TEXT), 'subject' => $this->_decode($email->subject()), 'from_email' => key($email->from()), 'from_name' => current($email->from()), 'to' => [], 'headers' => ['Reply-To' => is_null(key($email->replyTo())) ? key($email->from()) : key($email->replyTo())], 'recipient_metadata' => [], 'attachments' => [], 'images' => []];
// Merge Mandrill Parameters
$message = array_merge($message, Hash::merge($this->defaultParameters, $email->profile()['Mandrill']));
// Add receipients
foreach (['to', 'cc', 'bcc'] as $type) {
foreach ($email->{$type}() as $mail => $name) {
$message['to'][] = ['email' => $mail, 'name' => $name, 'type' => $type];
}
}
// Attachments
$message = $this->_attachments($email, $message);
// Create a new scoped Http Client
$this->http = new Client(['host' => 'mandrillapp.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP Mandrill Plugin']]);
// Sending as a template? Then in case we find mail content, we add this as a 'template_content'.
// In you Mandrill template, use <div mc:edit="content"></div> to get the contents of your email
if (!is_null($message['template_name']) && $message['html']) {
if (!isset($message['template_content']) || !is_array($message['template_content'])) {
$message['template_content'] = [];
}
$message['template_content'][] = ['name' => 'content', 'content' => $message['html']];
}
// Are we sending a template?
if (!is_null($message['template_name']) && !empty($message['template_content'])) {
return $this->_sendTemplate($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
} else {
return $this->_send($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
}
}
示例2: _prepareMessage
/**
* Prepares the message body.
*
* @return string
*/
protected function _prepareMessage()
{
$lines = $this->_cakeEmail->message();
$messages = array();
foreach ($lines as $line) {
if (!empty($line) && $line[0] === '.') {
$messages[] = '.' . $line;
} else {
$messages[] = $line;
}
}
return implode("\r\n", $messages);
}
示例3: send
/**
* Send mail
*
* @param \Cake\Network\Email\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(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc'));
$to = $headers['To'];
unset($headers['To']);
foreach ($headers as $key => $header) {
$headers[$key] = str_replace(array("\r", "\n"), '', $header);
}
$headers = $this->_headersToString($headers, $eol);
$subject = str_replace(array("\r", "\n"), '', $email->subject());
$to = str_replace(array("\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 array('headers' => $headers, 'message' => $message);
}