pietbez Posted March 6, 2008 Share Posted March 6, 2008 So what is the big secret with mass mailing. i have searched forums, scripts, freelancers and everything i can think of but just cant get info about it. i have a db of about 3000 registered members. i need to mail a newsletter on a regular basis. the php script that i use works fine for small batches, but wont send more than 300 at a time. it pulls the newsletter from a bd, and also pulls the emails from a db. what is the "right way" to do this. Batch mails? multiple smtp's? i have had several freelance scripter work on this but cant solve my problem. is there a single corect way to do this, is my approach way off the mark? please help, or point me in the right direction. Link to comment https://forums.phpfreaks.com/topic/94813-mass-mailer/ Share on other sites More sharing options...
amites Posted March 7, 2008 Share Posted March 7, 2008 essentially 2 ways, 1 is a good script that can queue the mailings, send off 20 - 100 at a time with a 10 minute pause between sends the other way is to send them all out as a single message making all the emails a BCC quite a few scripts that can queue up mail, try testing a few out, if you still have trouble send me a message and I'll see if I can help Link to comment https://forums.phpfreaks.com/topic/94813-mass-mailer/#findComment-485613 Share on other sites More sharing options...
corbin Posted March 7, 2008 Share Posted March 7, 2008 How are the messages sending now? If you're using the native mail() function, that's where the 300 max is coming into play. mail() opens a new connection every email. Link to comment https://forums.phpfreaks.com/topic/94813-mass-mailer/#findComment-485615 Share on other sites More sharing options...
pietbez Posted March 7, 2008 Author Share Posted March 7, 2008 this is the script i am using at the moment. is this script badly written? can i modify this script to work corectly or should i start from scrach with a new approach? all i need is to know that my newsletter is going out to all my members. what is the most effective, batch or bcc? <? include('../functions.php'); if(!$_SESSION['admin_logged_in']) { header('Location: ' .LOGIN_URL ); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin | Send mass mail</title> <link href="style.css" rel="stylesheet" type="text/css" media="all" /> <body> <? $letter_id = ( !empty($_REQUEST['letter_id']) ) ? $_REQUEST['letter_id'] : FALSE; $msg=''; $let_info=get_letter($letter_id); $letter_title=$let_info['name']; $hf=get_hf(); if (isset($_REQUEST['submit_preview'])) { $ready_to_send = true; $letter_body=''; $letter_body=$hf['header'].'<br>'.$let_info['content'].'<br>'.$hf['footer'].'<br>'; } if (isset($_REQUEST['submit_mass_mail'])) { $info=get_mass_mails(); $members=$info['items']; $oks=$bads=$invalids=0; $letter_body=''; $headers=''; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: dorp <[email protected]>'. "\r\n"; $headers .= 'Reply-To: [email protected]' . "\r\n"; $hf_header_tmp = $hf['header']; $let_info_tmp .= $let_info['content']; for ($i=0; $i<$info['total']; $i++) { $name = $members[$i]['name']; $email = $members[$i]['email']; if (valid_mail($email)) { //$headers .= "To: $name <$email>" . "\r\n"; $hf['header'] = str_replace('[name]', $name, $hf_header_tmp); $hf['footer'] = str_replace("[email]", $email, $hf['footer']); $let_info['content'] = str_replace('[name]', $name, $let_info_tmp); $letter_body =$hf['header'].'<br>'.$let_info['content'].'<br> <img src="http://www.xxxx.co.uk/cpanel/mail.php?id='.$letter_id.'&u='.$members[$i]['id'].'">'.$hf['footer'].'<br>'; $letter_body = str_replace("\n.", "\n..", $letter_body); if (mail($email, $letter_title, $letter_body, $headers)) ++$oks; else ++$bads; } else { ++$invalids; } } $all=$oks+$bads+$invalids; $msg="<br>Mailing reports:<br> <br>Letter: #$letter_id - $letter_title<br> <br>Sent: $oks <br>Failed: $bads<br> <br>Invalid E-mails: $invalids<br> <br>Total: $all ."; create_log_entry($_SESSION['auth_literal_admin_level'].' '.$_SESSION['auth_admin_name'].$msg,$_SESSION['auth_admin_name'],'mailing'); // } ?> <br /> <script language="javascript" type="text/javascript"> function disableForm(theform) { if (document.all || document.getElementById) { for (i = 0; i < theform.length; i++) { var tempobj = theform.elements[i]; if (tempobj.name.toLowerCase() == "submit_mass_mail" || tempobj.type.toLowerCase() == "submit_preview") tempobj.disabled = true; } } } </script> <form id="form1" name="form1" method="post" action="mass_mailer.php?letter_id=<? echo $letter_id; ?>"><!-- onSubmit="return disableForm(this);" --> <table width="685" border="0" align="center" cellpadding="0" cellspacing="1" class="input_form"> <tr> <th colspan="2" scope="row">Send mass mail </th> </tr> <tr> <td colspan="2" class="style7" scope="row"> </td> </tr> <tr> <td width="85" class="style7" scope="row">Choose letter </td> <td width="412"> <select name="letter_id" id="letter_id"> <? $eq = get_letters(); $eq_info = $eq['items']; for ($i=0; $i<$eq['total']; $i++) { if ($eq_info[$i]['id'] == $letter_id) $chx='selected="selected"'; else $chx=''; echo "<option value='{$eq_info[$i]['id']}' $chx>{$eq_info[$i]['name']}</option>\r\n"; } ?> </select> <input name="submit_preview" type="submit" id="submit_preview" value="Preview!" /></td> </tr> <? if ($ready_to_send) {?> <tr> <td colspan="2" scope="row"><span class="style7"> You are about to send a mass mail to <? echo count_members(); ?> members of your site </span></td> </tr> <tr> <td colspan="2" class="header" scope="row"><div align="center"><span class="style7"> </span>** Letter preview below ** <span class="style7"> </span></div> </td> </tr> <tr> <td colspan="2" scope="row"><? echo $letter_title ; ?></td> </tr> <tr> <td colspan="2" scope="row"><? echo $letter_body ; ?></td> </tr> <tr> <td colspan="2" class="header" scope="row"><div align="center"><span class="style7"> </span>** end preview ** <span class="style7"> </span></div></td> </tr> <tr> <td colspan="2" scope="row"><div align="center"> <script language="javascript"> function write_message(letter_id) { alert(letter_id); //document.write('Please be patient while mailing list is processed! This may take a while, depending on the total users...'); } </script> </div></td> </tr> <tr> <td colspan="2" scope="row"> <div align="center"> <input name="submit_mass_mail" type="submit" id="submit_mass_mail" value="Send mass mail!" /> <span class="error"><br />(press only once and wait the page to load completely!)</span></div></td> </tr> <? ;} ?> <tr> <td colspan="2" scope="row"> <div align="left" class="error"> <? if ($msg!='') {echo $msg;} ?> </div> </td> </tr> </table> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/94813-mass-mailer/#findComment-485623 Share on other sites More sharing options...
corbin Posted March 8, 2008 Share Posted March 8, 2008 If you're using mail() there's a great chance that the script is going to sputter to a stop after a few hundred emails.... If you check your variables, does it tell you all of the emails sent? Link to comment https://forums.phpfreaks.com/topic/94813-mass-mailer/#findComment-486829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.