Mail ([receiver], [subject], [mail subject], [header information]);
You simply need to replace the [receiver] with the next name in the list. Suppose you already have an array of email addresses:
$addresses = Array ("me@mycompany.com", "you@yourcompany.com", "someone@otherplace.com");
All you have to do is loop through the array, get the new address, and then send the message.
If you have a list of e-mail addresses in the database, the same principle applies: iterate through them.
You've learned the ropes. Obviously, the same concept is true for your particular database type and table structure, although the code will need to make some changes.
People seem to overlook the point of looping through an address list: If you have more than 50 addresses to deal with, your script will probably time out before it's done, Because PHP has a default time limit of 30 seconds for each script to run. You can modify this time limit but be careful when doing so. Limit this change to a specific script, such as traversing a script that sends a message to an address list. Otherwise, you might be able to overload the server's threads with your own hands, Then your computer will crash and never be the same.
To set a time limit in your script, you can use the Set_time_limit () function. You can set a time limit, say 60 seconds (Set_time_limit (60)), or you can keep it running straight through it (set_time_limit (0)).
Add this code to your script, and your email address traversal loop will work happily until the message is sent to all the addresses in the list.
Sending HTML-formatted emails is also an easy thing to do. Once you've learned how to do this, you may be kicking yourself because you thought it was hard.
We need to make two changes to the mail script we've written:
Your email should be in HTML format.
You must add Content-type header information.
This is all the things to do. A recipient who can read an HTML-formatted e-mail client will see their mail with a large, bold-format letter. If you send an HTML format message that includes an image label, you must remember to use the full URL in the SRC attribute, for example:
You should also remember that not everyone is able to read HTML-formatted emails and those who can't read this format can only see the HTML code itself. It's annoying, so it's better to think twice.
Conclusion
You can use PHP in any way, method or any form imaginable. This tutorial simply provides the basics: Configure your server and send a simple message. You can also send an attachment to an e-mail message that you create with the mail () function to modify a whole bunch of different header information. There are things you can do with any email client program and mailing list sending program.