Welcome Guest, Not a member yet? Register   Sign In
Using php for automatic emailing

I have a php file containing a list of 365 quotes and a script for displaying them on my ExpressionEngine-based website. (This script was created by another developer.)

Now I need to be able to modify this script so it can automatically email a 'quote of the day' to my mailing list.

I'm trying to figure out the php code I need to be able to do this type of automatic mailing.

Can anyone offer any tips for getting this done?


Edited above.

I can't say for sure how to integrate it into EE or CI directly as I've never done that, but I have set up plenty of auto mailing scripts in PHP. If you want this to occur on a regular schedule then you'll need to make sure that your host will let you setup a cron task (for an Apache web server).

The basic steps will be getting a list of emails from the database. You can do this using PHP's built-in database functions if you can't hook into your EE/CI database class. Then loop through the results and send the email. PHP has a built-in mail() function that works most of the time, but for more flexibility you could look into using the PHPMailer class, available on Sourceforge. Then just schedule the script to run from the command line in the cron job, with something like `/path/to/php -e your_email_script.php`

There are plenty of tutorials on sending email with PHP and setting a PHP script to run under cron, so if you're still stuck you can always check Google.

Good luck!

Thanks! You've given me plenty to get started with.

Theme © iAndrew 2016 - Forum software by © MyBB