Skip to content

Instantly share code, notes, and snippets.

@sandys
Last active October 10, 2018 21:08
Show Gist options
  • Save sandys/7f436e1a4a998aa62b954a5188290fe7 to your computer and use it in GitHub Desktop.
Save sandys/7f436e1a4a998aa62b954a5188290fe7 to your computer and use it in GitHub Desktop.
R code to send email using Amazon SES
# first install mailR. It is a bit funky to install this because of the dependency on rJava
#First install java
### sudo add-apt-repository ppa:webupd8team/java
### sudo apt-get update
### sudo apt-get install oracle-java8-installer
#now you can install mailR. The assumption is that java is in /usr/lib/jvm/jdk1.8.0_66/. Check if a newer version has changed the directory
sudo JAVA_HOME=/usr/lib/jvm/jdk1.8.0_66/ R CMD javareconf
sudo JAVA_HOME=/usr/lib/jvm/jdk1.8.0_66/ Rscript -e 'install.packages(c("mailR"), .Library.site[1], repos="http://cran.us.r-project.org", dependencies=TRUE)'
# now you can run the following script
library(mailR)
smpt_auth <- list(host.name="email-smtp.eu-west-1.amazonaws.com", port=25, user.name="kkkk", passwd="ppp", ssl=TRUE)
send.mail(from="[email protected]",to="[email protected]", subject="Test file attach R", body = "test script", html=T, smtp=smpt_auth, authenticate=T, encoding="utf-8",attach.files="/tmp/Sample_DB.xlsx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment