Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email from mysql using php

Status
Not open for further replies.

34534534534555

IS-IT--Management
Jan 8, 2003
240
0
0
GB
Hi!

I have a standard database that is populated from a php page, collecting people's email addressess and some other information. Unitl now i have been copying the addresses into Outlook and sending them email.

Now, because of expected increasing volume, i want, on my admin page, the ability to input some text into a form and then send emails with it as the body and the email addresses extracted from the database. Additionally, each email must be seperate, ie, people must not be able to see one another's email address. Not so importantly, but preferably i would like to be able to include a picture in the email body -is this possible?

So obv, there is a need for a loop here. Can all this be done using php mail() or do i need an add-on module or something else entirely..

The volume isn't huge, <500 at the moment but potentially <5000.

I greatly appreciate any advice.
 
Have a look at PHPMailer which is available at phpmailer.sourceforge.net
It offers HTML mail and you should then send the mail out with the recipients in the Bcc: field (blind carbon copy).
 
You can use a while statement to loop through the email addresses and send out mail.

$body = $_POST['body']; // text you typed into the form
while ($rec=mysql_fetch_assoc($result)) {
mail($rec['emailaddress'],$subject,$body,$from);
}

Just a thought.

 
Thank you both for your reply's. PHPMailer certainly seems to include a lot of functionality. I will need to spend some time working through it.

I am trying to do all of this on a Apache/MySQL/PHP setup that is localhost on my home machine before i upload.

Can you tell me how SMTP comes into it. This is the send function on an email server, right? Must i have an SMTP, as i don't on my development machine.

Many Thanks.


| Feedback is always appreciated as this will help to further our knowledge as well |
 
Local box with what OS?
If you have a Linux type system you can use sendmail.
For Windows it is entirely a different story.
The most important thing to check out is if the production environment has the same setup as the developmen, best, if the development setup matches the production.
Also I recommend that you put the mail function in a custom function, so even if the mail method is different you just have to rewrite or swap out the generic function and not all calls to a PHP native function (it's called a custom wrapper).
 
Hi DRj478,

Thanks for your help.

I am on OS X so i use sendmail i guess (i need to install it as it isn't pre installed, what a pain!) i know my host uses a linux server with sendmail. so i'll try and perfect the code and then upload it to test.

....just got to perfect the code now!!


| Feedback is always appreciated as this will help to further our knowledge as well |
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top