![]() |
|
Snippets |
|
It can be tricky sending email from a batch script (e.g. for cron use), here's how to do it. Start with your usual batch setup:
define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); define('SF_APP', 'app_name'); define('SF_ENVIRONMENT', 'environment'); define('SF_DEBUG', true); require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); sfContext::getInstance();
You can set attributes directly from the batch script if you wish:
sfContext::getInstance()->getRequest()->setAttribute('key', $value);
Then forward on to another module/action to handle processing and forwarding to mail as usual:
sfContext::getInstance()->getController()->forward('action', 'module');