我有以下代码:
text <- 'sample'
sender <- "***"
recipients <- c("***")
send.mail(from = sender,
to = recipients,
subject = text,
body = text,
smtp = list(host.name = "smtp.gmail.com", port = 465,
user.name = "***",
passwd = "***", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
在我的情况下,text变量是从数据库中获取的值,但这使得它更容易。当我在本地机器上运行时,上面的代码工作正常。但是当我在Linux Ubuntu上运行时,完全相同的代码会给我以下错误:
org.apache.commons.mail.EmailException: Sending the email to the following
server failed : smtp.gmail.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
at org.apache.commons.mail.Email.send(Email.java:1437)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl. java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43)
有人能告诉我在Linux环境中出现这个错误的原因是什么(而不是在我本地运行时)?