我正在尝试在 R 中使用 sendemailR 包,但我收到一个错误,我不知道如何解决。
尝试默认参数时:
library(sendmailR)
from <- "your_email"
to <- "your_email"
subject <- "Test send email in R"
body <- "It works!"
mailControl=list(smtpServer="smtp.gmail.com")
sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
我得到错误
Error in socketConnection(host = server, port = port, blocking = TRUE) :
cannot open the connection
In addition: Warning message:
In socketConnection(host = server, port = port, blocking = TRUE) :
Gmail SMTP Server:25 cannot be opened
所以我将端口更改为 465,它似乎可以工作
library(sendmailR)
from <- "your_email"
to <- "your_email"
subject <- "Test send email in R"
body <- "It works!"
mailControl=list(smtpServer="smtp.gmail.com", smtpPort="465")
sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)
但后来我收到以下错误
Error in if (code == lcode) { : argument is of length zero
知道发生了什么吗?
这是 R 和 Windows 的版本
R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
谢谢!