本文整理汇总了PHP中Swift_Message::setContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Message::setContentType方法的具体用法?PHP Swift_Message::setContentType怎么用?PHP Swift_Message::setContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_Message
的用法示例。
在下文中一共展示了Swift_Message::setContentType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildMessage
/**
* (non-PHPdoc)
* @see AppCommon\CommonMailBundle.MailBuilder::buildMessage()
*/
public function buildMessage($body, $subject, $recipient = null)
{
$message = new \Swift_Message();
$message->setFrom($this->container->getParameter('mailer_sender'), $this->container->getParameter('mailer_sender_name'));
$message->setSubject($subject);
$message->setBody($body);
$message->setContentType('text/html');
if (null !== $recipient) {
$message->setTo($recipient);
}
return $message;
}
示例2: sendMail
/**
* {@inheritdoc}
*/
public function sendMail($subject, $body, $toMail = null, $fromMail = null, $html = true)
{
$message = new \Swift_Message($subject, $body);
if (!$toMail) {
$toMail = $this->toMail;
}
if (!$fromMail) {
$fromMail = $this->fromMail;
}
if ($html) {
$message->setContentType('text/html');
}
$message->setFrom($fromMail);
$message->setTo($toMail);
$this->logger->info(sprintf('Try register mail from L91 FormBundle: ' . PHP_EOL . ' From: ' . $fromMail . PHP_EOL . ' To: ' . $toMail . PHP_EOL . ' Subject: ' . $subject));
return $this->mailer->send($message);
}
示例3: processEmail
/**
* Prepare the email message.
*/
public function processEmail()
{
$this->count = 1;
$mail = new Swift_Message();
$mail->setContentType('text/plain');
$mail->setCharset('utf-8');
if ($this->getOption('use_complete_template', true)) {
$mail->setBody(sprintf(<<<EOF
------
%s - %s
------
%s
------
EOF
, $this->options['name'], $this->options['email'], $this->options['message']));
} else {
$mail->setBody($this->options['message']);
}
$mail->setSender(array(sfPlop::get('sf_plop_messaging_from_email') => sfPlop::get('sf_plop_messaging_from_name')));
$mail->setFrom(array($this->options['email'] => $this->options['name']));
if ($this->getOption('copy')) {
$mail->setCc(array($this->options['email'] => $this->options['name']));
$this->count++;
}
if (is_integer($this->getOption('receiver'))) {
$receiver = sfGuardUserProfilePeer::retrieveByPK($this->getOption('receiver'));
if ($receiver) {
$mail->setTo(array($receiver->getEmail() => $receiver->getFullName()));
} else {
$mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name')));
}
} else {
$mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name')));
}
if ($this->getOption('subject')) {
$mail->setSubject($this->getOption('subject'));
} else {
$mail->setSubject(sfPlop::get('sf_plop_messaging_subject'));
}
$this->mail = $mail;
}
示例4: streamToMime
/**
* Merges an OutputByteStream to Swift_Message.
*
* @param Swift_OutputByteStream $fromStream
* @param Swift_Message $message
*/
protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
{
$bufferLength = 78;
$headerData = '';
$fromStream->setReadPointer(0);
while (($buffer = $fromStream->read($bufferLength)) !== false) {
$headerData .= $buffer;
if (false !== strpos($buffer, "\r\n\r\n")) {
break;
}
}
$headersPosEnd = strpos($headerData, "\r\n\r\n");
$headerData = trim($headerData);
$headerData = substr($headerData, 0, $headersPosEnd);
$headerLines = explode("\r\n", $headerData);
unset($headerData);
$headers = array();
$currentHeaderName = '';
foreach ($headerLines as $headerLine) {
// Line separated
if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) {
$headers[$currentHeaderName] .= ' ' . trim($headerLine);
continue;
}
$header = explode(':', $headerLine, 2);
$currentHeaderName = strtolower($header[0]);
$headers[$currentHeaderName] = trim($header[1]);
}
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
$messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF');
$messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF');
$messageHeaders = $message->getHeaders();
// No need to check for 'application/pkcs7-mime', as this is always base64
if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) {
if (!preg_match('/boundary=("[^"]+"|(?:[^\\s]+|$))/is', $headers['content-type'], $contentTypeData)) {
throw new Swift_SwiftException('Failed to find Boundary parameter');
}
$boundary = trim($contentTypeData['1'], '"');
$boundaryLen = strlen($boundary);
// Skip the header and CRLF CRLF
$fromStream->setReadPointer($headersPosEnd + 4);
while (false !== ($buffer = $fromStream->read($bufferLength))) {
$messageStream->write($buffer);
}
$messageStream->commit();
$messageHeaders->remove('Content-Transfer-Encoding');
$message->setContentType($headers['content-type']);
$message->setBoundary($boundary);
$message->setBody($messageStream);
} else {
$fromStream->setReadPointer($headersPosEnd + 4);
if (null === $this->headerFactory) {
$this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory');
}
$message->setContentType($headers['content-type']);
$messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding']));
$messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition']));
while (false !== ($buffer = $fromStream->read($bufferLength))) {
$messageStream->write($buffer);
}
$messageStream->commit();
$message->setBody($messageStream);
}
}
示例5: createMessage
/**
* @param $subject
* @return $this
*/
public function createMessage($subject)
{
$this->message = \Swift_Message::newInstance($subject);
$this->message->setContentType("test/html");
return $this;
}
示例6: addInlineImagesToMessage
protected function addInlineImagesToMessage(\Swift_Message &$message, $fieldhtml)
{
$regex = '~data:[^;]+;[A-Za-z0-9]+,[^")\'\\s]+~';
preg_match_all($regex, $fieldhtml, $treffers, PREG_OFFSET_CAPTURE);
$treffers = $treffers[0];
foreach ($treffers as $treffer) {
$trefferexpl = explode(',', $treffer[0], 2);
$data = explode(';', $trefferexpl[0]);
$data = explode(':', $data[0]);
$mimetype = $data[1];
$decoded = base64_decode($trefferexpl[1]);
$image = new \Swift_Image();
$image->setBody($decoded, $mimetype);
$cid = $message->embed($image);
$fieldhtml = str_replace($treffer[0], $cid, $fieldhtml);
}
$message->setContentType("text/html")->setBody($fieldhtml, 'text/html');
return true;
}
示例7: inviteNewUser
private function inviteNewUser($email, $mailer)
{
$username = md5(rand(1000, 9999));
$password = md5(rand(1000, 9999));
$user = new sfGuardUser();
$user->username = $username;
$user->password = $password;
$user->groups[] = Doctrine::getTable('sfGuardGroup')->createQuery('a')->where('a.name = ?', 'leerling')->fetchOne();
$user->Profile = new sfGuardUserProfile();
$user->Profile->email = $email;
$user->Profile->is_invite = true;
$user->save();
$user->Profile->save();
$name = sprintf('%s (%s)', $this->getUser()->getGuardUser()->getFullname(), $this->getUser()->getUsername());
$url = $this->getController()->genUrl(sprintf('@invite_accept?username=%s', $username), true);
$message = new Swift_Message();
$message->setFrom('DNS Leergemeenschap Site');
$message->setSubject('Uitnodiging DNS Leergemeenschap');
$message->setContentType('text/html');
$message->setBody("Hallo, <br /><br />\n\nJij bent door {$name} uitgenodigd om deel te nemen aan de de DNS Leergemeenschap site.<br /><br />\n\n<a href=\"{$url}\">Klik hier om de uitnodiging aan te nemen</a><br /><br /><br /><br /><br /><br />\n\n{$url}");
$recipients = new Swift_RecipientList();
foreach (sfConfig::get('app_feedback_feedback_email', array('dnsleergemeenschap@gmail.com')) as $recipient) {
$recipients->addTo($recipient);
}
$mailer->send($message, $recipients, $this->getUser()->getEmail());
}
示例8: backup_module_log_error
/**
* Send error log to administrator
*
* @param array $errors
* @return boolean
*/
function backup_module_log_error($errors, $send_email = false)
{
$log_message = is_foreachable($errors) ? implode("\n", $errors) : $errors;
if ($send_email) {
$mailer =& ApplicationMailer::mailer();
$recipient = new Swift_Address();
$recipient->setAddress(ADMIN_EMAIL);
$recipient->setName('activeCollab admin');
$sender = new Swift_Address();
$sender->setAddress(ConfigOptions::getValue('notifications_from_email'));
$sender->setName(ConfigOptions::getValue('notifications_from_name'));
$tmp_message = "Automatic backup of activeCollab on " . ROOT_URL . " failed.\n\r";
$tmp_message .= "Backup returned these errors: \n\r\n\r";
$tmp_message .= $log_message;
$message = new Swift_Message();
$message->setSubject('activeCollab automatic backup error log');
$message->setData($tmp_message);
$message->setContentType('text/plain');
$mailer->send($message, $recipient, $sender);
}
// if
log_message($log_message, LOG_LEVEL_ERROR, 'backup');
}
示例9: setContentType
/**
* {@inheritdoc}
*
* @return $this|self
*/
public function setContentType($type) : self
{
$this->message->setContentType($type);
return $this;
}
示例10: setContentType
/**
* Specifies the format of the message (usually text/plain or text/html).
*
* @param string $contentType
*
* @return $this
*/
public function setContentType($contentType)
{
$this->message->setContentType($contentType);
return $this;
}