Jump to content

Recommended Posts

Hi Guys,

 

i'm at stale mate with my mass-emailing form! the way i have coded it so far there is a drop down box with:

 

MASS E-MAIL ALL CUSTOMERS

email1

email2

email3

 

you can select the top one which emails everyone or select individual emails

 

<?php
 case "mass-email":
 
   // How many emails
   $q_num = "SELECT * FROM `fcp_customers`";
   $r_num = mysql_query($q_num);
   $n_num = mysql_num_rows($r_num);
 
   print("<form action=\"admin.php?page=mass-email\" method=\"POST\">");
 
   // Mass e-mails form
   print("<table width='80%' border='0' cellpadding='5' cellspacing='1' />\n");
   print("<tr>\n");
   print("<th colspan='2'>Mass E-Mail Customers</th>\n");
   print("</tr>\n"); 
   print("<tr>\n");
   print("<td class='td_style' align='left' valign='top'>E-Mail:</td><td class='td_style' align='left'><select name=\"cus_emails\"><option value=\"email_all\">--> MASS EMAIL ALL CUSTOMERS! - ($n_num) <--</option>");
   
   $q_emails = "SELECT * FROM `fcp_customers`";
   $r_emails = mysql_query($q_emails);
   
   // Loop
   while ($a_emails = mysql_fetch_array($r_emails))
   {
    // Customers email
    $emails = $a_emails['email'];
    
    // Print
    print("<option value=\"$emails\">$emails</option>");
   }
   
   print("</select></td>\n");
   print("</tr>\n"); 
   print("<tr>\n");
   print("<td class=\"td_style\" align='left' valign=\"top\">E-Mail Subject:</td><td class='td_style' align='left'><input type=\"text\" name=\"cus_subject\" size=\"70\"></td>");
   print("</tr>\n"); 
   print("<tr>\n");
   print("<td class=\"td_style\" align='left' valign=\"top\">E-Mail Message:</td><td class='td_style' align='left'><textarea name=\"cus_message\" rows=\"20\" cols=\"70\"></textarea></td>");
   print("</tr>\n"); 
   print("<tr>\n");
   print("<td colspan='2' class='td_style' align='right'><input type='submit' name='submit_emails' class=\"btn_style\" value='Send!'></td>\n");
   print("</tr>\n");    
   print("</table>");
   
   print("</form>");
   
   // Deal with the submission
   if (isset($_POST['submit_emails']))
   {
     // Post vars
     $c_e = $_POST['cus_emails'];
     $c_s = $_POST['cus_subject']; 
     $c_m = $_POST['cus_message']; 
     
     // Mass or single email
     if ($c_e == 'email_all')
     {
       // Mass email
       $emails_array = array($emails);
       
       print_r($emails_array);
  
       } else {   
        
       // Single email      
       $to = "$c_e";
       $subject = "$c_s";
       $from = "info@firstchoicepharmacy.co.uk";
      $body = "<h3>Newsletter from firstchoicepharmacy.co.uk</h3>";
       $body .= "<br />";
       $body .= "$c_m<br /><br />";
       $body .= "Regards <br /><a href=\"http://www.firstchoicepharmacy.co.uk\">http://www.firstchoicepharmacy.co.uk</a>";
       $headers = "MIME-Version: 1.0\r\n";  
       $headers .= "From: firstchoicepharmacy.co.uk<$from>\n"; 
       $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";  
    
       $mail = mail($to,$subject,$body,$headers);
     
       // Success
       if ($mail)
       {
         print("<br /><span class=\"mail_ok\"><img src=\"images/tick.png\"> You have successfully emailed [ <b>$to</b> ]</span><br /><br /><br />");
       }
      
     }
   
   } // End main isset
 
 break;
?>

 

emailing singly works great but im not sure how to go about doing the mass emailing part?

 

any help would be great

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/121002-mass-emailing/
Share on other sites

According to PHP manual,

The mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

For the sending of large amounts of email, see the » PEAR::Mail, and PEAR::Mail_Queue packages.

 

Link to comment
https://forums.phpfreaks.com/topic/121002-mass-emailing/#findComment-623779
Share on other sites

To build onto waynewex's post, I see what you're doing as spam too.

 

In the US (if I remember correctly) and possibly other countries too, any periodic email that is based off of a mailing list must have an "unsubscribe" option.

 

 

 

Now to be constructive:

 

 

I've used PHPMailer for a couple hundred emails before, and it worked perfectly for me.

 

Haven't used it with more than that though.

Link to comment
https://forums.phpfreaks.com/topic/121002-mass-emailing/#findComment-623842
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.