Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory implications of sending email

Status
Not open for further replies.

bradoirs

Technical User
Jul 8, 2009
35
GB
I have recently converted a subscription only newsletter to email sending email with attachment. All works well even when looped to send multiple emails from database. What is noticeable is that after sending even a few everything seems to slow down after emails have been sent - is there some buffer somewhere or some other memory implication that needs to be cleared once a message has been sent?

$ok = @mail($email, $email_subject, $email_message, $headers);
if($ok) {
echo "The file $thefile was successfully sent! $email ($thename)";
} else {
echo "Sorry but the email $thefile could not be sent. Please go back and try again!";
}
 
Windows php4 (yes I know there is 5 now) and mysql
 
in windows the mail() function connects to a host for each mail that you send. that is not an asynchronous task so the script has to spend the time for each external routing before continuing to the next mail.

this can be eased by setting up an smtp relay on the same box as your php server (so the connection is over the loopback rather than external). But this risks your mails being rejected for spam however. and you must make sure that you don't leave the relay as an open relay.

better perhaps would be to use a linux server and hand off the mail tasks to sendmail. you can get linux servers in the cloud for $5 a month which will be fine for reasonable mail shots.

or use a mailshot program which may have optimisation built in. phpmailer has a mail shot extension available.

 
Thank you so much I understand the reasons why there is a memory useage but should that memory not be released once the email procedures are complete or is there some way to release the memory manually?
 
it is not memory issues. it's just the time for the mails to be sent sequentially.

if you are running a localhost SMTP then it may appear to you that the mails are sent because the php script has been finished. but in fact they are just queued. the 'slowness' you are experiencing will be your computer using processor time to send the mails in the background.

so run your mailshots from the cloud where the sending time is irrelevant to your desktop.

it is 'good' for each mail to be spaced out, by the way. as sometimes centralised spam engines flag mail (and thus senders) as spam if the same mail is seen more than x times by their servers within y seconds.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top