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
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.
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!
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
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"
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?
Pretty straight forward.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()
You never know everything, I learn everyday!
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
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!
mcolton (07-10-2014)
Bookmarks