Wait until an email has been received for specific recipient
zzhelqzkov opened this issue · 1 comments
zzhelqzkov commented
Will it be possible to add functionality to wait for the arrival of an email destined for a specific recipient?
That's my solution:
public function waitForReceiveAnEmailToEmail(string $recipientEmail, int $timeout = 10)
{
$condition = function () use ($recipientEmail) {
$emails = $this->mailer->fetchMessages();
foreach ($emails as $email) {
$constraint = Assert::equalTo($recipientEmail);
if ($constraint->evaluate($email->to_email, '', true)) {
return true;
}
}
return false;
};
$message = sprintf('Waited for %d secs but no email with recipient %s has arrived', $timeout,
$recipientEmail);
$this->mailtrapWait($timeout)->until($condition, $message);
}
foxted commented
For sure! I don't actively work on this project anymore, but feel free to submit a PR :)