You can absolutely achieve that using PHP's mail()
function.
However, if you plan to use the HTML format for your emails, i highly recommend using one of the prepared libraries around. My favourite is SwiftMailer.
When it comes to blacklisting, your best bet is either one of these:
- Use a clearly whitelisted proxy
- Use a different proxy for each email, rotating as many proxies as are available to you
- Make sure you have varying delays in between the sending of your emails
The latter can be accomplished be either one of these methods:
- Create a script that just sleeps for certain amount of time between sending the messages
Example
foreach($recipients as $rcp) {
mail($rcp, 'subject', 'content');
sleep(rand(1,20));
}
This will send a message from your queue and leave a varying delay of 1 to 20 seconds in between.
If you use a method such as this one, please make sure that your maximum execution time is configured properly, otherwise the script will die after a certain amount of time.
ini_set('max_execution_time', '3600');
This will have your script run for a maximum of one hour.
Your other option:
- Use a cron job that periodically executes your script
In this case you could write your current recipient to a file and increase that counter on each execution of the script.
I think in your case the previous method would be more suitable.
Please note
Sending bulk or spam can be illegal under certain conditions. As it was discussed in the comments to your question, you should always provide an unsubscribe option (e.g. a link) in your message.
Also note that it is hard to tell which recipient servers use which method in order to identify suspicious clients / client hosts. Using a method such as the one supplied above is no guarantee that the target server won't blacklist you.