# Emailing: How to execute "ar\_sendmail" using "RailsCron"

**URL:** <https://www.ruby-forum.com/t/emailing-how-to-execute-ar-sendmail-using-railscron/158598>\
**Category:** Rails\
**Created:** [January 25, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/emailing-how-to-execute-ar-sendmail-using-railscron/158598 "2009-01-25T18:06:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [January 25, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/emailing-how-to-execute-ar-sendmail-using-railscron/158598/1 "2009-01-25T18:06:53Z")

</div>

Hi there,

I’d like to know how to get “ar\_sendmail” (a command from the gem  
“ar\_mailer”) executed using the plugin “RailsCron”:

FYI: “RailsCron” is a way to execute background tasks using your Ruby on  
Rails environment. The RailsCron object is an ActiveRecord, so you can  
manipulate it in familiar ways:

RailsCron.create(  
:command =\> “Object.do\_something()”,  
:start =\> 2.minutes.from\_now,  
:every =\> 12.hours, # default: 1.day  
:finish =\> 2.years.from\_now # optional  
)

I know that “ar\_sendmail” is a command that could be executed  
a) manually, using the command line (at the root of the rails app), or  
b) automatically, using a conventional cron job.

But how do I write the code to have “ar\_sendmail” executed from within  
my RoR environment (as in the code above)?

Thanks for any solutions & sorry for being a n00b 😉 !  
Tom
