CodeIgniter Forums
Using php for automatic emailing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Using php for automatic emailing (/thread-18268.html)



Using php for automatic emailing - El Forum - 04-30-2009

[eluser]ramonekalsaw[/eluser]
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?

Thanks.


Using php for automatic emailing - El Forum - 05-01-2009

[eluser]ramonekalsaw[/eluser]
Edited above.


Using php for automatic emailing - El Forum - 05-01-2009

[eluser]Chrisbloom7[/eluser]
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!


Using php for automatic emailing - El Forum - 05-11-2009

[eluser]ramonekalsaw[/eluser]
Thanks! You've given me plenty to get started with.