Results 1 to 7 of 7

Thread: Get email addresses from mysql database and make an array to send an email

  1. #1
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    106
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Get email addresses from mysql database and make an array to send an email

    What I would like to do is get all the email addresses from my MySQL database and put them into the bcc of an email.
    Or get all the email addresses from my MySQL database and put them into a semicolon delimited list.
    Thanks for any help
    Last edited by mcolton; 07-10-2014 at 01:27 AM.

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    Sounds like a good idea, what exactly is the problem you're having? We aren't going to code it for you. Post back with what you're having trouble with.
    You never know everything, I learn everyday!

  3. #3
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    374
    Thanks
    5
    Thanked 35 Times in 33 Posts

    Default

    Here is what i think you are looking for:
    http://www.w3schools.com/php/php_mail.asp
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

  4. #4
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    106
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    I already use the mail function in many of my programs. That's not the problem.
    I can select the addresses from the database but I don't know how to get them into some form (array???) that I can plug into the email I want to send.
    The other problem is I want to put this email list into "bcc", not the "To"

  5. #5
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    Unless these people all know each other it's a bad idea to bcc a list of people like that. Why can't you just concatenate a string of email addresses with a , between them?
    PHP Code:
    $results $dbh->fetchAll($sql); // Simply assuming you're using PDO.  This is just an example from a DB query.
    $emails_only = array();

    foreach(
    $results as $r)
    {
       
    $emails_only[] = $r['email'];
    }

    $email_string implode(", "$emails_only); // Use this var as your To in the mail() 
    Pretty straight forward.
    You never know everything, I learn everyday!

  6. #6
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    106
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Why is bcc a bad idea. I have about 250 email addresses in my database. If I email them in the "To:", my email server cuts me off as a spammer.
    Thanks for the code. I think I'll use something like that in the future

  7. #7
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    Even if you bcc the list it will still send 250 emails. The server doesn't care how you are sending them, it still considers each address and email sent to. You server shouldn't spam you if you have non-spam content and all the proper headers and use the correct practices for sending emails. I would say it's a good possibility that your server will spam you if you simply use the mail() alone. You should use a php mailing library like phpmailer. It will output all the correct header info when sending.

    Understand that sending emails is not just a simple "send" kind of thing. There is a tremendous amount of stuff that goes into it. Simply sending via the mail() will most likely send most emails to the junk folder of the recipient.

    The reason for the bcc being bad is that for the first email sent will have everyone's email address visible to that person.
    You never know everything, I learn everyday!

  8. The Following User Says Thank You to fastsol1 For This Useful Post:

    mcolton (07-10-2014)

Similar Threads

  1. Create Email list from mysql database
    By mcolton in forum Looking for such a script or service
    Replies: 3
    Last Post: 08-21-2014, 04:36 AM
  2. Replies: 2
    Last Post: 08-16-2012, 01:10 AM
  3. send email in C
    By david.kansal in forum Other
    Replies: 1
    Last Post: 05-09-2011, 09:23 AM
  4. Replies: 2
    Last Post: 05-28-2008, 04:16 AM
  5. A script that collects email addresses?
    By danno in forum Looking for such a script or service
    Replies: 3
    Last Post: 04-07-2007, 02:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •