I am using Swift Mailer in Laravel 5.1 to send email. In my other projects the same code is working fine. But, in this project it is showing an exception when I try to embed an inline image.
The error:
FatalErrorException in StreamBuffer.php line 163:
Maximum execution time of 30 seconds exceeded
- in StreamBuffer.php line 163
Code for sending mail:
$transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com',587,'tls')
->setUsername('myemail@gmail.com')
->setPassword('mypasword');
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance('my subject');
$client = Client::query()->findOrFail($id);
$data = [
'login' => $client['contact_email'],
'password' => $client['password'],
'image' => $message->embed(\Swift_Image::fromPath(asset('resources/assets/images/mail_logo.jpg'))),
];
$message->setTo([$client['contact_email'] => $client['name']]);
$message->setFrom(['myemail@gmail.com' => 'My Name']);
$message->setBody(view('emails.registrationConfirmation',$data)->render(),'text/html');
$mailer->send($message);
My email file:
<img src="{{ $image }}" alt="Mail Logo" class="text-center"/>
<p>Dear Member,</p>
<br/>
<p>Your account has been verified.</p>
<br/>
<p>Your current login name : <b>{{ $login }}</b></p>
<p>Your login password is : <b>{{ $password }}</b></p>
<br/>
<p>The My Company</p>
<br/>
<p>If this is not yours account or this email sent by mistake, please contact with us. <a href="http://ift.tt/1VfnVqz">Contact us</a></p>
When I comment 'image' => $message->embed(\Swift_Image::fromPath(asset('resources/assets/images/mail_logo.jpg'))),
this line the mail is sending of course without the image. When I try to send an embedded image it shows the above exception.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire