Answers.Body: <p>I would think you would want to instead set up a controller action, as URLs route directly to them, rather than use the overhead of a page.</p>
  
  <p>Your cron job could hit the corresponding Controller Action URL (i.e., <a href="http://mysite.com/actions/myplugin/entriescreated/weekly" rel="nofollow">http://mysite.com/actions/myplugin/entriescreated/weekly</a>), and run your job like that. Note, where you're accessing an action via cron you would have to set it to allow anonymous access to the action.</p>
  
  <p><a href="http://buildwithcraft.com/docs/plugins/controllers" rel="nofollow">http://buildwithcraft.com/docs/plugins/controllers</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-31T16:09:18.557Z
Answers.Text: Took me a minute to wade through that, but I got it. All working!!! Thanks!
Answers.UserDisplayName: Herb Himes
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-31T16:13:47.567Z
Answers.Text: Question. I tested by just physically going to the action url. It returned a 404 page on the site. Is there a way to precent action urls from doing this?
Answers.UserDisplayName: Herb Himes
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-31T17:41:07.653Z
Answers.Text: You'll need to trigger some sort of response to keep it from doing this: http://craftcms.stackexchange.com/questions/5401/controller-action-works-but-still-gives-404
Answers.UserDisplayName: Patrick Harrington
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-31T15:28:48.057Z
Answers.LastActivityDate: 2015-07-31T15:28:48.057Z
Answers.UserDisplayName: Patrick Harrington
Body: <p>I'm very new to this so any guidance is greatly appreciated. I've written a couple of simple plugins that will send an email to admins on new user save and and on new entry creation. What I need to do now is to send a weekly email with all new entries created in the last 7 days to a particular user group. I figured it'd be pretty efficient to set up an online CRON job to hit a site url, and on load of that page, trigger my email plugin. However, I'm not sure how to trigger my plugin on page load. Any suggestions? </p>
  
Tags: <plugin-development><plugins><emails>
Title: Is it possible to have Craft send an email on page load?
ThreadText: # Is it possible to have Craft send an email on page load?
  
  (Asked by: username_0 on 2015-07-31)
  
  I'm very new to this so any guidance is greatly appreciated. I've written a couple of simple plugins that will send an email to admins on new user save and and on new entry creation. What I need to do now is to send a weekly email with all new entries created in the last 7 days to a particular user group. I figured it'd be pretty efficient to set up an online CRON job to hit a site url, and on load of that page, trigger my email plugin. However, I'm not sure how to trigger my plugin on page load. Any suggestions?
  
  **Tags:** plugin-development, plugins, emails
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-07-31. Score: 4 | Accepted answer
  
  I would think you would want to instead set up a controller action, as URLs route directly to them, rather than use the overhead of a page.
  
  Your cron job could hit the corresponding Controller Action URL (i.e., <http://mysite.com/actions/myplugin/entriescreated/weekly>), and run your job like that. Note, where you're accessing an action via cron you would have to set it to allow anonymous access to the action.
  
  <http://buildwithcraft.com/docs/plugins/controllers>
  
  > **Comments:**
  > **username_0**: Took me a minute to wade through that, but I got it. All working!!! Thanks!  
  > **username_0**: Question. I tested by just physically going to the action url. It returned a 404 page on the site. Is there a way to precent action urls from doing this?  
  > **username_1**: You'll need to trigger some sort of response to keep it from doing this: http://craftcms.stackexchange.com/questions/5401/controller-action-works-but-still-gives-404  
  
  ---
  
  