swiftmailer

How to test email in functional test (Symfony2)

本秂侑毒 提交于 2019-12-12 08:07:07
问题 I'm trying to test email in functional test... My source code is the same as the example of the cookbook, the controller : public function sendEmailAction($name) { $message = \Swift_Message::newInstance() ->setSubject('Hello Email') ->setFrom('send@example.com') ->setTo('recipient@example.com') ->setBody('You should see me from the profiler!') ; $this->get('mailer')->send($message); return $this->render(...); } And the test : // src/Acme/DemoBundle/Tests/Controller/MailControllerTest.php use

How to send spool from swiftmailer without using command

你。 提交于 2019-12-12 07:54:34
问题 How to send spool from swiftmailer without using command? php app/console swiftmailer:spool:send --env=prod I need to put this somehow into php file so that Server admin can add this to Schedule. 回答1: Just do the same that the command does. From the command Execute() function: $mailer = $this->getContainer()->get('mailer'); $transport = $mailer->getTransport(); if ($transport instanceof \Swift_Transport_SpoolTransport) { $spool = $transport->getSpool(); if ($spool instanceof \Swift

Catch swiftmailer exception in Symfony2 dev env controller

扶醉桌前 提交于 2019-12-12 07:48:53
问题 Im not sure why Im not catching exceptions from Swiftmailer in my controller. What am I doing wrong, or missing? In a controller I have: try { $this->get('mailer')->send($email); } catch (\Swift_TransportException $e) { $result = array( false, 'There was a problem sending email: ' . $e->getMessage() ); } It seems to get caught by Symfony before it gets to my code, so instead of being able to handle the error myself I get the standard 500 page with Swift_TransportException: Connection could

SwiftMailer Connection could not be established with host

旧时模样 提交于 2019-12-12 06:08:45
问题 I am getting an unexpected problem with emails being sent from my site. It had been working fine for some time and all of a sudden seems to have stopped for no apparent reason. [Swift_TransportException] exception 'Swift_TransportException' with message 'Connection could not be established with host [Connection timed out #110]' in vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:265 In my web.php 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'transport' => [

PHP Why Can't EOM contain PHP functions? [duplicate]

让人想犯罪 __ 提交于 2019-12-12 03:48:51
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Calling PHP functions within HEREDOC strings I am using Swiftmailer PHP to create an order complete page. When the customer lands on this page, I use an include to a PHP file. This page file has SwiftMailer EOM HTML that gets sent to the customer. However I have the HTML parts in chunks, so the header is via a function called header and order totals are the same too. I want to be able to include EOM functions

Sendmail Subject in Laravel 5.1

耗尽温柔 提交于 2019-12-12 03:33:13
问题 I want send email with subject using variable , this is code public function sendmail(Request $request) { $data = [ 'subject' => $request->input('subject'), 'name' => $request->input('name'), 'phone' => $request->input('phone'), 'email' => $request->input('email') ]; Mail::send('mail.sendmail' , $data, function($msg){ $msg->from('mygmail.com', 'Avil'); $msg->to('mygmail@gmail.com', 'Avil')->subject('Welcome to Laravel 5.1'); }); return redirect()->route('contact.index'); } I wanna subject not

Variables not replaced in Twig template

心已入冬 提交于 2019-12-12 02:37:58
问题 I have this PHP code (just using Twig + SwiftMailer): # Load Twig and swiftmailer require_once('lib/SwiftMailer/swift_required.php'); require_once('lib/Twig/Autoloader.php'); Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('views'); $twig = new Twig_Environment($loader, array( 'cache' => 'cache', )); $mailer = Swift_Mailer::newInstance(Swift_MailTransport::newInstance()); # Render twig template to a string $template = $twig->loadTemplate('email.twig'); $body = $template-

How can I keep track of mail sent using PHP Swift Mailer?

ぐ巨炮叔叔 提交于 2019-12-12 02:34:17
问题 I am using PHP Swift Mailer to send a bulk mail to a set of users. But I am not able to keep track of sent mail. My code: <?php require_once("includes/database.class.php"); require_once("lib/swift_required.php"); $con=DBClass::getConnection(); $db=DBClass::getDatabase($con); $login_id="myloginname"; $password="mypassword"; $to_mail; //list of people //Create the Transport $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl") ->setUsername($login_id) ->setPassword(

Laravel 4.2 Loging Mails from Swift Mailer

跟風遠走 提交于 2019-12-12 02:24:28
问题 In my project I need to log each mail I send from my application. Mail::queue('email.template', $vars, function($message) { $message->to('someone', 'Her name')->subject("<3"); LogModel::log($message); }); and in LogModel public static function log(Message $message) { $msg = $message->getSwiftMessage(); $log = new self; $log->to = $msg->getTo(); $log->subject = $msg->getSubject(); $log->cc = $msg->getCc(); $log->bcc = $msg->getBcc(); $log->body = $msg->getBody(); $log->headers = serialize($msg

How to solve Swift_TransportException Connection to ssl Timed Out error?

*爱你&永不变心* 提交于 2019-12-12 01:41:47
问题 I have a problem send email using Yii, the problem is sometime it result in ssl timeout, but some time mail send is going well. The error says something like this Swift_TransportException Connection to ssl://in-v3.mailjet.com:465 Timed Out Here is the error image After reading some article, it's looks like because socket is timeout so it should start socket again. Here is my article that I read. swiftmailer and Yii2 not working 1 out of 10 time How to close Smtp connection in SwiftMailer Here