473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to send e-mail to multiple recipients from database individually

6
hi i'm currently sending multi email recipients in one go is it possible to send it individually? please help thank you.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'library/config.php';
  3. ?>
  4.  
  5.  <?php
  6.  
  7.   $qe = "SELECT `cust_id`, `cust_name`, `cust_email`, `cust_phone`, `cust_address`, `cust_city`, `cust_state`, `cust_country`, `cust_pin`, `cust_spec_note` FROM `sland_pizza_customer` WHERE 1";
  8.   $re = dbQuery($qe);
  9.   if(dbNumRows($re)>0)
  10.   {
  11.   while($ra = dbFetchAssoc($re)):
  12.   $cust_email .=$ra['cust_email'].","." ";
  13.   endwhile; 
  14.   }
  15.  
  16.  
  17.  
  18. $to  = $cust_email; // sender
  19. $subject = 'Get 5% Discount Every Order';
  20.  
  21. // To send HTML mail, the Content-type header must be set
  22. $headers  = 'MIME-Version: 1.0' . "\r\n";
  23. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  24. $headers .= 'From: yoursite Penrith<newsletter@yoursite.com.au>' . "\r\n";
  25.  
  26. // Put your HTML here
  27. $message = file_get_contents('marketing.html');
  28.  
  29. // Mail it
  30. mail($to, $subject, $message, $headers);
  31. echo "It's Sent";
  32. ?>
Sep 25 '14 #1
10 4043
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Instead of appending all the email addresses together, move the mail stuff into your loop.
Sep 25 '14 #2
franda
6
hi Rabbit thanks for help but that did not fix my problem its still showing all the email recipients that the emails where sent to, i want every customer to see only they email when they open the email

example: From: newsletter@yoursite.com and To: customer@whatever.com


instate of From: newsletter@yoursite.com
To: customer@whatever.com, customer2@whatever.com, customer3@whatever.com, customer4@whatever.com.
Sep 25 '14 #3
Rabbit
12,516 Expert Mod 8TB
Please show the new code.
Sep 26 '14 #4
franda
6
its same as the above code, it does not sends them one by one! it sends them all together, i want to send them one by one. thanks Rabbit
Sep 26 '14 #5
Rabbit
12,516 Expert Mod 8TB
You said "that did not fix my problems". The implication is that you made the code changes I suggested. But then you said there is no new code. Which means you didn't make the code changes I suggested.

You need to make the changes I suggested in my first post then post the new code if you are still having issues.
Sep 26 '14 #6
franda
6
here is the updated code, it says "It's Sent" but i dont see any emails coming thank you Rabbit

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'library/config.php';
  3.  
  4.  
  5.  $qe = "SELECT `cust_id`, `cust_name`, `cust_email`, `cust_phone`, `cust_address`, `cust_city`, `cust_state`, `cust_country`, `cust_pin`, `cust_spec_note` FROM `sland_pizza_customer` WHERE 1";
  6.   $re = dbQuery($qe);
  7.   if(dbNumRows($re)>0)
  8.   {
  9.  
  10.  
  11.    $num=dbNumRows($re);
  12.  
  13.  
  14.     while ($i < $num)
  15.  
  16. {
  17.  
  18.     $cust_name='$row[cust_name]';
  19.  
  20.     if($qe == TRUE)
  21.  
  22. {
  23.  
  24.  
  25. $to  ='$row[cust_email]'; // sender
  26. $subject = 'Get 5% Discount Every Order';
  27.  
  28. // To send HTML mail, the Content-type header must be set
  29. $headers  = 'MIME-Version: 1.0' . "\r\n";
  30. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  31. $headers .= 'From: yoursite Penrith<newsletter@yoursite.com.au>' . "\r\n";
  32.  
  33. // Put your HTML here
  34. $message = file_get_contents('marketing.html');
  35.  
  36. // Mail it
  37. mail($to, $subject, $message, $headers);
  38. echo "It's Sent";
  39.  
  40.  
  41. $i++;
  42.  
  43. }
  44.  
  45. }
  46. }
  47.  
  48. ?>
Sep 27 '14 #7
Rabbit
12,516 Expert Mod 8TB
Why did you change your loop condition?
Sep 27 '14 #8
franda
6
what you suggest me to do, can you give me some code that i can just copy and paste thank you Rabbit
Sep 27 '14 #9
Rabbit
12,516 Expert Mod 8TB
This isn't a code writing service, we are here to help you learn what you did wrong so you can learn to be self sufficient.

What I am suggesting you do is to change your loop condition back to what it was. The only changes I suggested was to stop appending the addresses and to move the code around. You made way more changes than I suggested. Start with your original code again and only make the changes I originally suggested.
Sep 27 '14 #10
franda
6
looks like i did waste my time, im just gonna keep trying till i get it done. thanks anyway
Sep 28 '14 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
8
by: dccarson | last post by:
Here is a snippet of code which does not send to all recipients. However, it also does not inform me of this error. My suspicion is that this only fails for users with longer usernames. The two I...
15
by: news.microsoft.com | last post by:
HI, ASPEmail to send to multiple recipients? I tried to use comma and semicolon but all the time give this message error: Error: 6 - 501 Bad address syntax nor :...
2
by: .Net Newbie | last post by:
Hello, I am currently coding my ASP.Net pages in c# and have run into a question concerning Emails. I have four objects on a page (six including 2 buttons). The first is a subject line...
4
by: Michelle | last post by:
Hi Is it possible/anyone know how to send a document (.pdf) to multiple recipients using POP where the email is not just a matter of throwing 1000 email addresses in the BCC list, but each email...
1
by: Mr T | last post by:
I know how to send email from Access and I know how to create a custom form in Outlook. but.... How do I put the email info from Access into the Outlook custom form ??? Dim MyDB As Database Dim...
2
by: Lazareth | last post by:
Hi, I am trying to write a program to send email messages to selected recipients on a form when a button is clicked (each recipient has a checkbox) . The recipient section I can work out, but I...
2
by: shahnawaz shaikh | last post by:
hi friends i want to send email thoruth stored procedure or i want to give functionality like alert which is send email automaticaly from database. just like a news or any ad email weekly or...
4
by: cpanelxp | last post by:
hi, I have programmed a software that can send email to one recipient with this code In General Declaration I used this code Imports System.Net.Mail In Form Declaration I used this code
4
by: Wnicole | last post by:
I was hoping someone can look at this code and tell me what is missing It works all the way to outlook but once there it is not linking with the emails from the query on the report. It's sending the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.