I have a question Suppose i have one excel file in which 200 email addresses are saved i want to send an email to all of these and then the 2nd thing i want to email a newsletter or event reminder every month or whenever i want how this is accomplish using php. (I already know how to take data from excel file and put them in a mysql table but how to email or wat i have mentioned above) thanks in advance.
If you've already got the addresses in a mysql table, then you just need to do this: while($row = mysql_fetch_object(mysql_query("select * from emailtable"))) { mail($row->address, "Email Subject Here", "Message Body Here"); } PHP: Just read up on the proper ways to use the mail function: http://ca.php.net/manual/en/function.mail.php
Hi, it is easy export that file data into CSV format then write a php code that will ready CSV file line by line and send email to all. Thanks,
$row->address wat's this where shoild it comes from do i manually write the addresses ??? plz explain.
The code I posted assumes you've uploaded your list into a mysql table, as you said you already know how to do that. So let's say you've created a table called "emaillist" (or whatever you've called it), and have uploaded your big list of emails from excel. Let's also assume you have 3 columns in your table: email, fname and lname. The $row variable in the code I posted is a single row of your table, and the -> is a pointer to a specific column in that row. So $row->email refers to the "email" column of the specific row. The query I posted will pull every row from your table, and then execute the mail() function using the email address from each row. As you need to do is this: 1) Add in your mysql connection information (see mysql_connect) 2) Change 'emailtable' to whatever the name of the table is that you created in mysql 3) Change 'address' to whatever the column name is that you gave you table to store the email addresses. 4) Change 'Email Subject Here' to whatever you want the email to subject to be, and 'Message Body Here' to the spam you are sending them. 5) Execute the program, and it will do exactly what you are asking for. Check with your hosting company before you execute it though, mosts hosts these days will only allow you to send 100-200 emails/hour from your site, in which case there is a lot more coding to do. But this is enough to get you started.
Hi, Any code can allow that... but the hosting ppl wont.. you may have to shift to a better or an email host which will allow you to send unlimited emails. Thanks imphp