1

我有以下代码:

 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)

在我的例子中,文本变量是一个从数据库中获取的值,但这使它更容易。当我在本地机器上运行上面的代码时,它运行良好。但是,当我在 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 环境中出现此错误的原因是什么(而不是在我在本地运行时)?

4

0 回答 0