Sending email with R

In your daily tasks, you may need to repeatedly send email to your colleagues or boss after generating a set of reports. Fortunately, R can help you achieve this task with this brand new package.

All you need to do is to provide your gmail account then job is done. The trick is to correctly configure your account to allow for less secure app.

To achieve it, go the accounts and settings and select connected sites and applications then authorize less secure apps to access your account.

Now you can send email using your script and schedule it within a cron job (linux)

In Ubuntu, you may do the following:

    Generate reports every night at 10:

0 22 * * * bash "generate_reports.sh"

    Send email every Wednesday at 6 a.m:

0 06 * * 2 bash "send_email.sh"

    Where send_email.sh looks like the following:

#!/bin/bash
Rscript "send_email_report.R"