我只是尝试使用 mailR 包通过我的 gmail 帐户发送一封带有 R 的电子邮件,但它似乎不起作用。
我收到此错误:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : org.apache.commons.mail.EmailException: Sending the email to the following server failed : aspmx.l.google.com:25
下面是带有匿名 gmail 地址的代码。
install.packages("mailR")
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)
email$send() # execute to send email