When trying to send mail using swiftmailer I am getting the following error:
Expected response code 250 but got code "550", with message "550 User [email protected] has exceeded its 24-hour sending limit. Messages to 250 recipients out of 250 allowed have been sent. Relay quota will reset in 1.47 hours.
I have put the swiftmailer in the try catch block as follows:
public function sendMail($emailTemplateName, $subject, $body, $fromEmail, $toEmail)
{
try
{
return Yii::$app->mailer->compose(['html' => $emailTemplateName], ['emailBody' => $body])
->setFrom([ $fromEmail => Yii::$app->params['siteTitle'] ])
->setTo($toEmail)
->setSubject($subject)
->send();
}
catch(Swift_SwiftException $exception)
{
return 'Can sent mail due to the following exception'.print_r($exception);
}
}
I also tried with Swift_SwiftException
and Exception
but exeption doesn't get caught.
How can I handle this exception?
Ok got it. I needed to use \Swift_TransportException
in catch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With