CyberJunkie
CyberJunkie

Reputation: 22674

Website performance when sending emails in php

I plan to send an excess amount of emails daily to my website users. I am using php. Will such a task affect the performance of my website? What can be done to prevent issues?

Note: Emails are sent with users consent and scheduled by them. No spamming.

Upvotes: 0

Views: 144

Answers (3)

iWantSimpleLife
iWantSimpleLife

Reputation: 1954

Instead of sending the email directly, why not create a database table to store the email details. and just write to that table each time you need to send an email.

Then have a scheduled task that occasionally queries this table and do the mail sending.

That way, you do not need to worry about the php page timing out. and in future, you can also pull the schedule task out and run it on a separate server if it uses too much resources.

Upvotes: 4

Jason Brumwell
Jason Brumwell

Reputation: 3550

My suggestion and the way we handle this is to utilize a message queue, we currently use Zend Frameworks Package, then from a cron job retrieve the queue and send the email. This enables us to increase performance and avoid delays in displaying the page to the user. Hope that helps!

Upvotes: 1

Abe Petrillo
Abe Petrillo

Reputation: 2447

Some off the top of my head:

  • If your on shared hosting, you may get shut down for attempted spamming
  • The server IP may get labelled as a spam source if your sending email to random people
  • Send the emails in a cronjob rather than in real time, that way you can do the email sending at non-peak times

Upvotes: 3

Related Questions