Reputation: 281
I use the following code below to send and email to a user from my register form, It works but it slows my register page down. if i click register with out the code bam done. but if i have it in place it take a while for the registration to complete. I am using php7 is there a way of speeding this up?
$from = "Mysite <[email protected]>";
$to = $email;
$subject = "Registration";
$body_message = "Hello!\n\n\n\nThank you for registering. \n\nYou must verify the email address associated with your account.
\n\n\nThis message was sent from an unmonitored account. Any responses will not be read.\nIf you have any questions or concerns, please contact [email protected]";
$headers = "From: $from\nReply-To: $from\nContent-Type: text/plain";
mb_send_mail($email, $subject, $body_message, $headers);
Upvotes: 0
Views: 80
Reputation: 2043
When sending emails via SMTP directly, the performance will vary and be unpredictable. Most architectures will use a queue and worker task to decouple this from the user experience, or a third party service like SendGrid which will do that for you as well as offer other bells and whistles.
Upvotes: 1