zaedfsh's avatar

Email takes too long to reach the recipient

I'm trying the email verification function of Laravel 12 now. It does work, but the email takes minutes to reach the recipient. The SMTP mail server I'm using works fine. The emails sent to the same recipient via the webmail interface or email clients using the same SMTP server take seconds to reach the recipients only. Are there any tricks to accelerate the email sending process on Laravel?

0 likes
6 replies
Glukinho's avatar

Try to send a test mail through tinker, will it come fast or long?

Do you use queue for mailables?

zaedfsh's avatar

Thanks! I tried to use tinker to send a test email as instructed at https://azishapidin.com/test-laravel-smtp-mail-via-tinker. It did reached the same recipient in seconds, just the response is different from "null", but "= Illuminate\Mail\SentMessage {#6374}".

I also tried the method provided at https://atymic.dev/tips/laravel-send-test-email/, and the test mail reached the recipient in minutes like the verification email did. The difference between these two tinker commands is the variable name: the faster email uses $message, while the slower one $msg, according to different tutorials. Is it the cause of the slowness of the verification email?

I searched the project for queue for mailables, but couldn't find anything related. BTW, this project is newly built by a Laravel starter from https://github.com/winsonloh/laravel-12-admin-panel.

Glukinho's avatar

@zaedfsh no, sending speed doesn't depend on variables names, only on duration of underlying actions.

Are you sure the problem is your mail is slowly sent? Can it be that you SEE it in a recipient mailbox with a delay? Some mail interfaces show new messages quite slow.

zaedfsh's avatar

@Glukinho Negative. The recipient email is provided by a reliable and robust provider, I've been using it for over a decade.

I acctually sent the slow test mail prior to the fast one, and it reached the recipient email 4 minutes later than the fast one sent later.

Here's the screenshot of these two received emails.

email received

Glukinho's avatar

@zaedfsh Show how exactly you send both test emails. You provided two links with two identical procedures, I don't believe the first always sends "quickly" and the second is always "slow".

And show your mailable class which is "slow".

Glukinho's avatar

Set MAIL_MAILER=log in .env file. Try to send email several times by different ways. Look how fast it appears in log file storage/logs/laravel.log.

If mail appears in log always quickly, then your problem is about your SMTP server - it delays sending for some reason. If the problem remains the same (emails appear in log with delays), it is about your code.

Please or to participate in this conversation.