Elen Elen - 10 months ago 54
R Question

Receive email notification when script ends

How easy is it to send e-mail through R?

using this

> library(sendmailR)
> from <- "myaddress@gmail.com"
> to <- "receiveraddress@gmail.com"
> subject <- "Performance Result"
> body <- "This is the result of the test:"
> mailControl=list(smtpServer="snmpt server address")
> sendmail(from=from,to=to,subject=subject,msg=body,control=list(smtpServer="ASPMX.L.GOOGLE.COM"))

I receive this error:

Error in wait_for(code) :
SMTP Error: 5.5.2 Syntax error. jp9si1521863wjb.204 - gsmtp

I guess I should make something from the side of gmail but what should I have to make?

I tried also this for gmail using real address but I didn't receive any error but neither any e-mail

sender <- "sender@gmail.com" # Replace with a valid address
recipients <- c("receiver1@gmail.com") # Replace with one or more valid addresses
email <- send.mail(from = sender,
to = recipients,
subject="Subject of the email",
body = "Body of the email",
smtp = list(host.name = "aspmx.l.google.com", port = 25),
authenticate = FALSE,
send = FALSE)

Answer Source

It works for me with slightly different smtp settings (host name, port and ssl and addition of user.name and passwd) and also with 'authenticate' and 'send' changed to TRUE.

send.mail(from = sender,
        to = recipients,
        subject = "Subject of the email",
        body = "Body of the email",
        smtp = list(host.name = "smtp.gmail.com", port = 465, 
                    user.name = sender, 
                    passwd = "senders_password", ssl = TRUE),
        authenticate = TRUE,
        send = TRUE)