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?
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?
@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 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".
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.