Case Case - 1 year ago 63
PHP Question

Slow or poor sendmail mail execution

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 <>";
$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";
$headers = "From: $from\nReply-To: $from\nContent-Type: text/plain";

mb_send_mail($email, $subject, $body_message, $headers);

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download