Sometimes my program can send a message and sometimes not, according to one of my colleagues it is because of the connectivity here in our place. Sometimes I can't ping the SMTP address.
Now I tried retrying to send the message in a loop, yet it doesn't because the program will stop because of an internal server error.
$mail_params = $params['mail'];
$transport = \Swift_SmtpTransport::newInstance($mail_params['smtp'], $mail_params['port'], $mail_params['encryption'])
->setUsername($mail_params['user'])
->setPassword($mail_params['password']);
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance($subject)
->setFrom([Yii::$app->params['notificationEmail'] => 'TMC Scheduler'])
->setTo([$to])
->setBody(trim($email_message));
while ($i = 0) {
$i = $mailer->send($message);
}
return $i
I've been stuck here 4 days. Do you guys have any ideas? I'm running out of it.