通过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)
答案 0 :(得分:0)
它适用于我的smtp设置略有不同(主机名,端口和ssl以及user.name和passwd的添加)以及&#39; authenticate&#39;和&#39;发送&#39;改为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)