How you can send unlimited emails with PHP

In this tutorial I want to create a simple php script with which I can send unlimited emails to all my clients.

At the first I need to create an database and a table with this fields: ID and email. I will create also a php  file and I will connect it to my database.

Next I will write this code:

$get_email = mysql_query("SELECT * FROM mytable"); // With this code I will extract all email addresses from my database.

while($email = mysql_fetch_array($get_email)):
send_to($email,$subject,$messagge,""); // with this code I will call my function that allows to send emails

in my php file.

Also, I will create a function like this

function send_to($email,$subject,$messagge,$from)
mail($email,$subject,$messagge,$from); // this function will send all emails to your clients

Shared hosting usually has limitations on sending emails. For this reason I recommend you to get a VPS hosting.

In my next tutorial I will explain to you how you can send a HTML email messagge with PHP.

Leave a Comment