i am using yii2 and swiftmailer to send job titles to subscriber of my website. i send every 24 hours or every 2 days…based on the new jobs posted in my website.
i have 300 subscribers, my hosting allow me to send 500 emails per a single hour.
here is my code
// the following code works fine, becuase the number of users between codeno 20…65= is 45
my students codeno starts with 1…
but if the number of students is beyond 45, it gives error… sending error", so solve this, i jus create multiple pages, but i want to solve this problem so that i can send to all my students.
if i make the following code, it will showing me sending error
/* ->andWhere([’>=’,‘codeno’, 10])
->andWhere([’<=’,‘codeno’, 100])
*/
public function sendJobEmail($email)
{
$students = Student::find()
->andWhere([’>=’,‘codeno’, 20])
->andWhere([’<=’,‘codeno’, 65])
->all();
try
{
foreach( $students as $student)
{
$body1 = Yii::$app->view->renderFile(’@common/mail/layouts/jobs.php’,
Yii::$app->mailer->compose()
->setTo($student->email)
->setFrom(array(‘info@mywebsite.com’ => ‘mywebsite.com’))
->setSubject(‘New Jobs posted’)
->setHtmlBody($body1)
->send();
{
throw new \Exception('Error sending the email to '.$student->email);
}
}
}
return true;
}
return 1;
}