脚本结束时接收电子邮件通知

Receive email notification when script ends

通过 R 发送电子邮件有多容易?

使用这个

> 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"))

我收到此错误:

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

我想我应该从 gmail 方面做点什么,但我应该做什么?

我也尝试过使用真实地址对 gmail 进行此操作,但我没有收到任何错误,但也没有收到任何电子邮件

library(mailR)
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)

它对我的 smtp 设置略有不同(主机名、端口和 ssl 以及 user.name 和 passwd 的添加)以及 'authenticate' 和 'send' 更改为 TRUE。

library(mailR)  
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)