Automatic mail sending |
[eluser]Roy MJ[/eluser]
Hi, I was wondering if there was any method for sending a static mail automatically. My need is that i have to send a mail for someones birthday who has registered his dob in my database. Is it possible to trigger a mail delivery automatically everyday. ??
[eluser]Roy MJ[/eluser]
Hey, Ive tried doing the cron job. But i cant find a way as to how the command will be like so that i can add a cron job via cpanel. * * * * * /usr/local/bin/php -q /home/public_html/system/application/controller/cron.php But i dont see it working. My cron.php looks like this : Code: <?php Can u please find what im doing wrong here. In cpanel i gave this command as cron job.. Code: $HOME/system/application/controller/cron.php
[eluser]Atharva[/eluser]
I suggest you use plain php to run your cron jobs rather than using CI. Also, why this statement is in constructor? Code: * * * * * /usr/local/bin/php5 $HOME/system/scripts/clean_cache.php
[eluser]Roy MJ[/eluser]
* * * * * /usr/local/bin/php5 $HOME/system/scripts/clean_cache.php When i googled i came across a page where it said the above line is the cron command. I used the below step too. But none of it is triggering the automatic mail sending. * * * * * /usr/local/bin/php5 $HOME/system/application/controller/cron.php Have you implemented the cron job anywhere??.
[eluser]Roy MJ[/eluser]
I did it in controller as eventually im planning to do mailing to emails selected from database. So first i was trying to get it working by static contents and static emails. I have found a Cron job application inside the cpanel in the advanced section. In that also we need to give a cron command. The command is what i had mentioned above. But its not working either. If you have done the mail sending, can you please tell me whats wrong with my code. I cant do it in simple php as it would mean i cant access the database.
[eluser]Atharva[/eluser]
I usually store my cron files in cron folders. You can also user the db config from system/application/database.php and config values from system/application/config.php in that file. Here is how I do it. Suppose there is a file email_cron.php Code: define( 'BASEPATH', dirname(__FILE__) ); This will include mentioned files, so you can access database settings, base_url etc. Below goes the email code you want to run Code: //select email query, mail code , etc.... You can set through cpanel when this cron will run, and the command will be path to this cron file. For sending mail, you can also use phpmailer. |
Welcome Guest, Not a member yet? Register Sign In |