本文整理汇总了PHP中Swift_Attachment类的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Attachment类的具体用法?PHP Swift_Attachment怎么用?PHP Swift_Attachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Swift_Attachment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _swiftMail
protected function _swiftMail($to, $from, $subject, $message, $attachments = [], $html = true)
{
$mailer = $this->__getSwiftMailer($from);
if (is_array($to) && isset($to['email'])) {
if (isset($to['name'])) {
$to = [$to['email'] => $to['name']];
} else {
$to = $to['email'];
}
}
$mail = new \Swift_Message();
$mail->setSubject($subject)->setFrom($from['email'], $from['name'])->setTo($to);
if (isset($from['reply-to'])) {
if (is_array($from['reply-to']) && isset($from['email'])) {
$mail->setReplyTo($from['reply-to']['email'], $from['reply-to']['name']);
} else {
$mail->setReplyTo($from['reply-to']);
}
}
$mail->setBody($message, $html ? 'text/html' : 'text/plain');
foreach ($attachments as $attachment) {
$mail->attach(\Swift_Attachment::fromPath($attachment));
}
return $mailer->send($mail);
}
开发者ID:mpf-soft,项目名称:mpf,代码行数:25,代码来源:MailHelper.php
示例2: sendBasic
/**
*
* @param array $o
* @throws InvalidArgumentException
* @return multitype:NULL string |multitype:NULL |number
*
*/
public function sendBasic(smMailMessage $smMailMessage, array $options)
{
$this->smMailMessage = $smMailMessage;
$message = Swift_Message::newInstance();
$this->setSMTPData($message, $options['account']);
$this->feedAddress($message, 'to', $this->smMailMessage->to);
$this->feedAddress($message, 'cc', $this->smMailMessage->cc);
$this->feedAddress($message, 'bcc', $this->smMailMessage->bcc);
$message->setFrom(array($smMailMessage->from => $smMailMessage->fromName ? $smMailMessage->fromName : $this->from));
$message->setSender($smMailMessage->sender);
$message->addReplyTo($this->smMailMessage->replyTo);
$message->setSubject($smMailMessage->subject);
$headers = $message->getHeaders();
if (count($this->customheaders) > 0) {
foreach ($this->customheaders as $kc => $vc) {
$headers->addTextHeader(array($kc, $vc));
}
}
foreach ($smMailMessage->attachments as $k => $v) {
$message->attach(Swift_Attachment::fromPath($v));
}
$type = $message->getHeaders()->get('Content-Type');
$type->setValue('text/html');
$type->setParameter('charset', $this->charset);
$message->setBody($smMailMessage->HTMLBody)->addPart($smMailMessage->HtmlToTextBody());
$success = $this->mailer->send($message, $error) > 0;
return array('success' => $success, 'mailStream' => $success ? $message->toString() : null, 'error' => $error);
}
开发者ID:micoli,项目名称:qd_mail,代码行数:35,代码来源:mailSenderSwiftMailer.php
示例3: attach
protected function attach($attachment)
{
if (!$attachment instanceof Swift_Attachment) {
$attachment = Swift_Attachment::fromPath($attachment);
}
return $this->message->attach($attachment);
}
开发者ID:alshabalin,项目名称:kohana-advanced-mailer,代码行数:7,代码来源:Mailer.php
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
//generacion xlsx
$em = $this->getContainer()->get('doctrine')->getManager();
$emailDara = $em->getRepository('BackendBundle:EmailList')->findOneByName('Email Dara');
$researches = $em->getRepository('BackendBundle:Research')->programationUnsendedToDara();
$date = date("d-M-Y h:i:s");
if (count($researches) == 0) {
$output->writeln($date . ": No hay programaciones para este periodo");
} else {
try {
$this->generateProgramacionXLSX($researches);
} catch (Exception $e) {
$output->writeln($e->getMessage());
return $e->getMessage();
}
$output->writeln($date . ": Programacion generada");
//enviar por email
$today = date("d-M-Y");
$filename = "Programacion_" . $today;
$path = $this->getContainer()->get('kernel')->getRootDir() . "/../web/Programaciones/";
$message = \Swift_Message::newInstance()->setSubject('Programación de Cursos IPre')->setFrom('[email protected]')->setTo(array($emailDara->getEmail()))->setBody("Hola, adjuntamos la programación de cursos de este mes, saludos, \nGestión IPre")->attach(\Swift_Attachment::fromPath($path . $filename . ".xlsx"));
$this->getContainer()->get('mailer')->send($message);
$output->writeln($date . ": Programacion enviada");
// seteamos los estados como programacion envada a dara
foreach ($researches as $research) {
$research->getApplication()->setState(4);
$em->flush();
}
}
}
开发者ID:ericksho,项目名称:sigi,代码行数:31,代码来源:SendProgramacionxlsxCommand.php
示例5: sendEmail
/**
* Send a email using t3lib_htmlmail or the new swift mailer
* It depends on the TYPO3 version
*/
public static function sendEmail($to, $subject, $message, $type = 'plain', $fromEmail = '', $fromName = '', $charset = 'utf-8', $files = array())
{
$mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setTo(explode(',', $to));
$mail->setSubject($subject);
$mail->setCharset($charset);
$mail->setFrom(array($fromEmail => $fromName));
$mail->setReplyTo(array($fromEmail => $fromName));
// add Files
if (!empty($files)) {
foreach ($files as $file) {
$mail->attach(Swift_Attachment::fromPath($file));
}
}
// add Plain
if ($type == 'plain') {
$mail->addPart($message, 'text/plain');
}
// add HTML
if ($type == 'html') {
$mail->setBody($message, 'text/html');
}
// send
$mail->send();
}
开发者ID:sorenmalling,项目名称:additional_scheduler,代码行数:29,代码来源:Utils.php
示例6: onFormProcessed
/**
* Send email when processing the form data.
*
* @param Event $event
*/
public function onFormProcessed(Event $event)
{
$form = $event['form'];
$action = $event['action'];
$params = $event['params'];
if (!$this->email->enabled()) {
return;
}
switch ($action) {
case 'email':
// Prepare Twig variables
$vars = array('form' => $form);
// Build message
$message = $this->buildMessage($params, $vars);
if (isset($params['attachments'])) {
$filesToAttach = (array) $params['attachments'];
if ($filesToAttach) {
foreach ($filesToAttach as $fileToAttach) {
$filesValues = $form->value($fileToAttach);
if ($filesValues) {
foreach ($filesValues as $fileValues) {
$filename = $fileValues['file'];
$message->attach(\Swift_Attachment::fromPath($filename));
}
}
}
}
}
// Send e-mail
$this->email->send($message);
break;
}
}
开发者ID:statrixbob,项目名称:gravblog,代码行数:38,代码来源:email.php
示例7: send
public function send($lastOverride = false)
{
$i18n = Localization::getTranslator();
$lastFn = '/home/pi/phplog/last-tx-sent';
$last = 0;
if (file_exists($lastFn)) {
$last = intval(trim(file_get_contents($lastFn)));
}
if ($lastOverride !== false) {
$last = $lastOverride;
}
$csvMaker = Container::dispense('TransactionCSV');
$config = Admin::volatileLoad()->getConfig();
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($config->getEmailUsername())->setPassword($config->getEmailPassword());
$msg = Swift_Message::newInstance()->setSubject($config->getMachineName() . $i18n->_(': Transaction Log'))->setFrom([$config->getEmailUsername() => $config->getMachineName()])->setTo(array($config->getEmailUsername()))->setBody($i18n->_('See attached for transaction log.'));
$file = $csvMaker->save($last);
if (!$file) {
throw new Exception('Unable to save CSV');
}
$msg->attach(Swift_Attachment::fromPath($file));
file_put_contents($lastFn, $csvMaker->getLastID());
$mailer = Swift_Mailer::newInstance($transport);
if (!$mailer->send($msg)) {
throw new Exception('Unable to send: unkown cause');
}
}
开发者ID:oktoshi,项目名称:skyhook,代码行数:26,代码来源:CSVMailer.php
示例8: sendMail
public function sendMail()
{
$transport = Swift_SmtpTransport::newInstance($this->instance, $this->smtp_port);
$transport->setUsername($this->username);
$transport->setPassword($this->user_password);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setFrom($this->setFrom);
$message->setTo($this->setTo);
$message->setSubject($this->subject);
$message->setBody($this->setBody, 'text/html', 'utf-8');
if (!empty($this->setfilepath)) {
$message->attach(Swift_Attachment::fromPath($this->setfilepath)->setFilename($this->aliasname));
}
/*try{
if($mailer->send($message)){
return true;
}
}
catch (Swift_ConnectionException $e){
//echo 'There was a problem communicating with SMTP: ' . $e->getMessage();
return false;
}*/
return $mailer->send($message);
}
开发者ID:syyzw1985,项目名称:lib,代码行数:25,代码来源:sendmail.php
示例9: send
static function send($title, $body, $to_array, $attachment = null, $log = true)
{
$model = Config::find()->one();
// Create the message
$message = \Swift_Message::newInstance()->setSubject($title)->setFrom(array($model->from_email => $model->from_name))->setTo($to_array)->setBody($body);
// Optionally add any attachments
if ($attachment) {
if (is_array($attachment)) {
foreach ($attachment as $file) {
$message = $message->attach(Swift_Attachment::fromPath($file));
}
} else {
$message = $message->attach(Swift_Attachment::fromPath($attachment));
}
}
// Create the Transport
switch ($model->type) {
case 1:
$transport = \Swift_SmtpTransport::newInstance($model->smtp, $model->port > 0 ?: 25)->setUsername($model->from_email)->setPassword($model->pass);
break;
case 2:
$transport = \Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
break;
case 3:
$transport = \Swift_MailTransport::newInstance();
break;
}
$mailer = \Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
//log send mail
if (true === $log) {
static::log($to_array, $title, $body, $attachment);
}
}
开发者ID:rocketyang,项目名称:mincms,代码行数:34,代码来源:Mailer.php
示例10: sendEmail
public static function sendEmail($receiver, $obj = "Aucun objet", $content = "", $urlFile = "", $nameFile = "")
{
global $config;
global $twig;
$message = Swift_Message::newInstance();
$template = $twig->loadTemplate("email_generique.html5.twig");
$view = $template->render(["objEmail" => $obj, "messageEmail" => $content]);
$arrMatches = array();
preg_match_all('/(src=|url\\()"([^"]+\\.(jpe?g|png|gif|bmp|tiff?|swf))"/Ui', $view, $arrMatches);
foreach (array_unique($arrMatches[2]) as $url) {
$src = rawurldecode($url);
// see #3713
if (!preg_match('@^https?://@', $src) && file_exists(BASE_ROOT . '/' . $src)) {
$cid = $message->embed(Swift_EmbeddedFile::fromPath(BASE_ROOT . '/' . $src));
$view = str_replace(array('src="' . $url . '"', 'url("' . $url . '"'), array('src="' . $cid . '"', 'url("' . $cid . '"'), $view);
}
}
$message->setSubject($obj);
$message->setFrom($config["smtp"]["sender"]);
$message->setReplyTo($config["smtp"]["replyTo"]);
$message->setTo($receiver);
$message->setBody($view, 'text/html');
if ($urlFile !== "") {
$message->attach(Swift_Attachment::fromPath($urlFile)->setFilename($nameFile));
}
$mailer = self::getMailer();
$mailer->send($message);
}
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:28,代码来源:EmailHelper.php
示例11: mailSender
/**
* Sends out an email to specified recipients using given message and other optional parameters.
* @param array $components Mixed value array containing components to create a message.
* @return integer number of recipients the message was sent to.
*/
function mailSender($components)
{
//Create transport
$transport = Swift_SmtpTransport::newInstance('insert mail/smtp server here', 25)->setUsername('insert username here')->setPassword('insert password here');
//Create mail using transport
$mailer = Swift_Mailer::newInstance($transport);
//Create message. Minimum required: from, to, subject, message.
$message = Swift_Message::newInstance();
$message->setSubject($components['subject'])->setFrom($components['from'])->setTo($components['to'])->setBody($components['body'], 'text/html');
//Optional parameters. Check to see if array contains additional parameters to add to the message.
if (array_key_exists('bcc', $components)) {
$message->setBcc($components['bcc']);
}
if (array_key_exists('cc', $components)) {
$message->setCc($components['cc']);
}
if (array_key_exists('attachment', $components)) {
if (is_array($components['attachment'])) {
foreach ($components['attachment'] as $attachment) {
$message->attach(Swift_Attachment::fromPath($attachment));
}
} else {
$message->attach(Swift_Attachment::fromPath($components['attachment']));
}
}
return $mailer->send($message);
}
开发者ID:huff-earl,项目名称:Dashboard-Web-Portal,代码行数:32,代码来源:mailsender.php
示例12: testAttachmentSending
public function testAttachmentSending()
{
$mailer = $this->_getMailer();
$message = Swift_Message::newInstance('[Swift Mailer] HtmlWithAttachmentSmokeTest')->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer'))->setTo(SWIFT_SMOKE_EMAIL_ADDRESS)->attach(Swift_Attachment::fromPath($this->_attFile))->setBody('<p>This HTML-formatted message should contain an attached ZIP file (named "textfile.zip").' . PHP_EOL . 'When unzipped, the archive should produce a text file which reads:</p>' . PHP_EOL . '<p><q>This is part of a Swift Mailer v4 smoke test.</q></p>', 'text/html');
$this->assertEqual(1, $mailer->send($message), '%s: The smoke test should send a single message');
$this->_visualCheck('http://swiftmailer.org/smoke/4.0.0/html_with_attachment.jpg');
}
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:7,代码来源:HtmlWithAttachmentSmokeTest.php
示例13: testSend
public function testSend()
{
$message = new Swift_Message();
$message->setFrom('[email protected]', 'Johnny #5');
$message->setSubject('Is alive!');
$message->addTo('[email protected]', 'A. Friend');
$message->addTo('[email protected]');
$message->addCc('[email protected]');
$message->addCc('[email protected]', 'Extra 2');
$message->addBcc('[email protected]');
$message->addBcc('[email protected]', 'Extra 4');
$message->addPart('<q>Help me Rhonda</q>', 'text/html');
$message->addPart('Doo-wah-ditty.', 'text/plain');
$attachment = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2 = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2->setDisposition('inline');
$message->attach($attachment);
$message->attach($attachment2);
$message->setPriority(1);
$headers = $message->getHeaders();
$headers->addTextHeader('X-PM-Tag', 'movie-quotes');
$messageId = $headers->get('Message-ID')->getId();
$transport = new PostmarkTransportStub('TESTING_SERVER');
$client = $this->getMock('GuzzleHttp\\Client', array('request'));
$transport->setHttpClient($client);
$o = PHP_OS;
$v = phpversion();
$client->expects($this->once())->method('request')->with($this->equalTo('POST'), $this->equalTo('https://api.postmarkapp.com/email'), $this->equalTo(['headers' => ['X-Postmark-Server-Token' => 'TESTING_SERVER', 'User-Agent' => "swiftmailer-postmark (PHP Version: {$v}, OS: {$o})", 'Content-Type' => 'application/json'], 'json' => ['From' => '"Johnny #5" <[email protected]>', 'To' => '"A. Friend" <[email protected]>,[email protected]', 'Cc' => '[email protected],"Extra 2" <[email protected]>', 'Bcc' => '[email protected],"Extra 4" <[email protected]>', 'Subject' => 'Is alive!', 'Tag' => 'movie-quotes', 'TextBody' => 'Doo-wah-ditty.', 'HtmlBody' => '<q>Help me Rhonda</q>', 'Headers' => [['Name' => 'Message-ID', 'Value' => '<' . $messageId . '>'], ['Name' => 'X-PM-KeepID', 'Value' => 'true'], ['Name' => 'X-Priority', 'Value' => '1 (Highest)']], 'Attachments' => [['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt'], ['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt', 'ContentID' => 'cid:' . $attachment2->getId()]]]]));
$transport->send($message);
}
开发者ID:wildbit,项目名称:swiftmailer-postmark,代码行数:30,代码来源:TransportTest.php
示例14: sendMessage
protected function sendMessage($templateName, $context, $fromEmail, $toEmail, array $attachments = array())
{
$template = $this->twig->loadTemplate($templateName);
$subject = $template->renderBlock('subject', $context);
$textBody = $template->renderBlock('body_text', $context);
$htmlBody = $template->renderBlock('body_html', $context);
$message = \Swift_Message::newInstance()->setSubject($subject)->setFrom($fromEmail)->setTo($toEmail);
if (!empty($htmlBody)) {
$message->setBody($htmlBody, 'text/html')->addPart($textBody, 'text/plain');
} else {
$message->setBody($textBody);
}
if (is_array($attachments) && !empty($attachments)) {
foreach ($attachments as $filename => $path) {
//TODO need to assure to use correct absolute path!
if (file_exists($path)) {
$attachment = \Swift_Attachment::fromPath($path);
if (is_string($filename)) {
$attachment->setFilename($filename);
}
$message->attach($attachment);
}
}
}
$this->mailer->send($message);
}
开发者ID:junjinZ,项目名称:wealthbot,代码行数:26,代码来源:TwigSwiftMailer.php
示例15: to
public static function to($email, $subject, $content, $part, $attach)
{
$mailconfig = Config::get('mail');
$transport = \Swift_SmtpTransport::newInstance($mailconfig['host'], $mailconfig['port'])->setUsername($mailconfig['username'])->setPassword($mailconfig['password']);
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create the message
$message = \Swift_Message::newInstance($subject)->setFrom(array($mailconfig['from']['address'] => $mailconfig['from']['name']));
// Set the To addresses with an associative array
if (!is_array($email)) {
throw new \Exception("发送邮件必须是关联数组", 1);
}
$message->setTo($email);
// Give it a body
$message->setBody($content);
// And optionally an alternative body
if ($part) {
$message->addPart($part, 'text/html');
}
// Optionally add any attachments
if ($attach) {
$message->attach(Swift_Attachment::fromPath($attach));
}
// Send the message
if (!$mailer->send($message, $failures)) {
return $failures;
} else {
return true;
}
}
开发者ID:xiaobeicn,项目名称:cfphp,代码行数:30,代码来源:Mail.php
示例16: postUpdate
public function postUpdate(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
$this->mailer = $this->container->get('mailer');
$this->mailerHelper = $this->container->get('stfalcon_event.mailer_helper');
$this->pdfGeneratorHelper = $this->container->get('stfalcon_event.pdf_generator.helper');
if ($entity instanceof Payment) {
if ($entity->getStatus() === Payment::STATUS_PAID) {
$tickets = $this->container->get('doctrine')->getManager()->getRepository('StfalconEventBundle:Ticket')->getAllTicketsByPayment($entity);
/** @var Ticket $ticket */
foreach ($tickets as $ticket) {
/** @var $user User */
$user = $ticket->getUser();
/** @var Event $event */
$event = $ticket->getEvent();
$successPaymentTemplateContent = $this->mailerHelper->renderTwigTemplate('StfalconEventBundle:Interkassa:_mail.html.twig', ['user' => $user, 'event' => $event]);
$mail = new Mail();
$mail->addEvent($event);
$mail->setText($successPaymentTemplateContent);
$html = $this->pdfGeneratorHelper->generateHTML($ticket);
$message = $this->mailerHelper->formatMessage($user, $mail);
$message->setSubject($event->getName())->attach(\Swift_Attachment::newInstance($this->pdfGeneratorHelper->generatePdfFile($ticket, $html), $ticket->generatePdfFilename()));
$this->mailer->send($message);
}
}
}
}
开发者ID:bolotyuh,项目名称:fwdays,代码行数:27,代码来源:PaymentListener.php
示例17: send
/**
* {@inheritdoc}
*/
public function send($from, $to, $subject, $body, $replyTo = null, $attachments = [])
{
$message = new \Swift_Message($subject, $body);
// set from and to
$message->setFrom($from);
$message->setTo($to);
// set attachments
if (count($attachments) > 0) {
foreach ($attachments as $file) {
if ($file instanceof \SplFileInfo) {
$path = $file->getPathName();
$name = $file->getFileName();
// if uploadedfile get original name
if ($file instanceof UploadedFile) {
$name = $file->getClientOriginalName();
}
$message->attach(\Swift_Attachment::fromPath($path)->setFilename($name));
}
}
}
// set replyTo
if ($replyTo != null) {
$message->setReplyTo($replyTo);
}
return $this->mailer->send($message);
}
开发者ID:alexander-schranz,项目名称:sulu-website-user-bundle,代码行数:29,代码来源:MailHelper.php
示例18: handle
/**
* Listen contact message request;
*/
private function handle(Request $request)
{
$email = $request->request->get('feedback_user_email');
$name = $request->request->get('feedback_user_name');
$email = $request->request->get('feedback_user_email');
$subject = $request->request->get('feedback_subject');
$message = $request->request->get('feedback_message');
$captcha = $request->request->get('g-recaptcha-response');
if (empty($email) || empty($message)) {
return;
}
if (!$this->captchaIsValid($captcha)) {
return;
}
$uploadedFile = $request->files->get('lampiran');
$attachedFile = false;
if ($uploadedFile) {
// NOTE: $attachedFile variable is used below for mail attachment
$attachedFile = $uploadedFile->getPath() . DIRECTORY_SEPARATOR . $uploadedFile->getClientOriginalName();
$uploadedFileSize = $uploadedFile->getSize();
$uploadedFileSizeLimit = static::fileUploadMaxSize();
if ($uploadedFileSize > $uploadedFileSizeLimit) {
// @todo change this to template
echo '<script>alert("FILE TOO BIG");</script>';
echo '<script>setTimeout(function(){ window.location = window.location.href }, 2000);</script>';
exit;
}
$uploadedFile->move($uploadedFile->getPath(), $uploadedFile->getClientOriginalName());
}
try {
$messageBody = sprintf(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'mail_format.php'), $name, $email, $subject, $message);
$smtpUser = $this->getOption('smtp_user');
$smtpPass = $this->getOption('smtp_pass');
$smtpHost = $this->getOption('smtp_host');
$smtpPort = $this->getOption('smtp_port', 465);
$smtpSsl = $this->getOption('smtp_ssl', 0);
$mailFrom = $smtpUser;
$mailFromName = $this->getOption('mail_from_name');
$mailTos = $this->getMailTos();
$message = Swift_Message::newInstance()->setSubject($subject)->setFrom($mailFrom, $mailFromName)->setTo($mailTos)->setBody($messageBody);
if ($attachedFile) {
$message->attach(\Swift_Attachment::fromPath($attachedFile));
}
if ($smtpSsl) {
$transport = Swift_SmtpTransport::newInstance($smtpHost, $smtpPort, 'ssl');
} else {
$transport = Swift_SmtpTransport::newInstance($smtpHost, $smtpPort);
}
$transport->setUsername($smtpUser)->setPassword($smtpPass);
$mailer = Swift_Mailer::newInstance($transport);
// Send the message
$result = $mailer->send($message);
if ($result) {
header("Location: " . get_site_url(NULL, 'contact') . '?contact-message-sent=1');
exit;
}
} catch (\Exception $e) {
throw $e;
}
}
开发者ID:egig,项目名称:wp-contact-form,代码行数:63,代码来源:EgigContactForm.php
示例19: mail
public function mail(CategoryEvent $event)
{
/** @var BaseHandler $handler */
$handler = $event->getParam('handler');
if ($handler) {
$dateFormat = 'Y-m-d h:i:s';
$mailer = new Mailer();
$mailer->setGroup('product');
$message = $mailer->getMessage();
$message->setSubject($handler->getUrl() . ' ' . date($dateFormat));
$body = 'Script started at: ' . date($dateFormat, $this->registry->startTime) . PHP_EOL;
$body .= 'Script finished at: ' . date($dateFormat) . '; Total execute time: ' . date('i:s', time() - $this->registry->startTime) . PHP_EOL;
$body .= 'Parsed urls: ' . $handler->getJobTotal() . PHP_EOL;
$message->setBody($body);
$fileParts = pathinfo($this->config->getParseDir() . $handler->getFileName());
$fname = $this->config->getParseDir() . $handler->getFileName();
file_exists($fname) ? $message->attach(\Swift_Attachment::fromPath($fname)) : null;
$fname = $this->config->getParseDir() . $fileParts['filename'] . '_disappeared_products.' . $fileParts['extension'];
file_exists($fname) ? $message->attach(\Swift_Attachment::fromPath($fname)) : null;
$fname = $this->config->getParseDir() . $fileParts['filename'] . '_newProducts.' . $fileParts['extension'];
file_exists($fname) ? $message->attach(\Swift_Attachment::fromPath($fname)) : null;
$fname = $this->config->getParseDir() . $fileParts['filename'] . '_recently_reviewed_products.' . $fileParts['extension'];
file_exists($fname) ? $message->attach(\Swift_Attachment::fromPath($fname)) : null;
$mailer->send();
}
}
开发者ID:sudevva,项目名称:parser2,代码行数:26,代码来源:ParseListener.php
示例20: testAttachmentSending
public function testAttachmentSending()
{
$mailer = $this->_getMailer();
$message = Swift_Message::newInstance()->setCharset('utf-8')->setSubject('[Swift Mailer] InternationalSmokeTest (διεθνής)')->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Χριστοφορου (Swift Mailer)'))->setTo(SWIFT_SMOKE_EMAIL_ADDRESS)->setBody('This message should contain an attached ZIP file (named "κείμενο, εδάφιο, θέμα.zip").' . PHP_EOL . 'When unzipped, the archive should produce a text file which reads:' . PHP_EOL . '"This is part of a Swift Mailer v4 smoke test."' . PHP_EOL . PHP_EOL . 'Following is some arbitrary Greek text:' . PHP_EOL . 'Δεν βρέθηκαν λέξεις.')->attach(Swift_Attachment::fromPath($this->_attFile)->setContentType('application/zip')->setFilename('κείμενο, εδάφιο, θέμα.zip'));
$this->assertEqual(1, $mailer->send($message), '%s: The smoke test should send a single message');
$this->_visualCheck('http://swiftmailer.org/smoke/4.0.0/international.jpg');
}
开发者ID:abouthalf,项目名称:archies-recipes,代码行数:7,代码来源:InternationalSmokeTest.php
注:本文中的Swift_Attachment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论