通过安全的 smtp 服务器发送带有囊胚的邮件失败 (r)

mid*_*iby 7 r blastula

我尝试使用 R 包blastula 发送电子邮件。电子邮件应该通过我雇主的安全 smtp 服务器发送,但我遇到了“没有可用的 Kerberos 凭据”错误。类似的设置在 python 中工作,但我想从 R 中完成,因为它更适合我的工作流程。

用于发送邮件的 r 代码显示在此处。

library(blastula)
email <- prepare_test_message()
to <- "receiver_address@gmail.com"
from <- "sender_address@domain.com"

create_smtp_creds_file(
  file = "cred_file",
  user = "username",
  host = "smtps.server.com",
  port = 465,
  use_ssl = TRUE
)
#> Please enter password in TK window (Alt+Tab)
#> The SMTP credentials file (`cred_file`) has been generated

smtp_send(email, to, from, 
          subject = "Hello", 
          credentials = creds_file(file = "cred_file"), 
          verbose = TRUE)
#> Error in curl::curl_fetch_memory(url, handle = h): Failure when receiving data from the peer
Run Code Online (Sandbox Code Playgroud)

reprex 包(v0.3.0)于 2019 年 12 月 10 日创建

smtp_send命令的详细输出如下:

* Rebuilt URL to: smtps://smtps.server.com:465/
*   Trying xx.xx.xx.xx...
* TCP_NODELAY set
* Connected to smtps.server.com (xx.xx.xx.xx) port 465 (#1)
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
*  subject: XXXXXXXX
*  start date: Apr 20 00:00:00 2017 GMT
*  expire date: Apr 23 12:00:00 2020 GMT
*  subjectAltName: host "smtps.server.com" matched cert's "smtps.server.com"
*  issuer: C=NL; ST=Noord-Holland; L=Amsterdam; O=TERENA; CN=TERENA SSL CA 3
*  SSL certificate verify ok.
< 220 mail.server.com Microsoft ESMTP MAIL Service ready at Tue, 10 Dec 2019 12:49:44 +0100
> EHLO henrik-HP-EliteBook-840-G5
< 250-mail.sdu.dk Hello [xx.xx.xx.xx]
< 250-SIZE 62914560
< 250-PIPELINING
< 250-DSN
< 250-ENHANCEDSTATUSCODES
< 250-STARTTLS
< 250-AUTH GSSAPI NTLM LOGIN
< 250-8BITMIME
< 250-BINARYMIME
< 250 CHUNKING
> AUTH GSSAPI
< 334 GSSAPI supported
* gss_init_sec_context() failed: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_501). 
* Closing connection 1
Error in curl::curl_fetch_memory(url, handle = h) : 
  Failure when receiving data from the peer
Run Code Online (Sandbox Code Playgroud)

和输出 sessionInfo()

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] blastula_0.3.1.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        compiler_3.6.1    prettyunits_1.0.2 remotes_2.1.0     tools_3.6.1       getPass_0.2-2    
 [7] testthat_2.3.1    digest_0.6.23     pkgbuild_1.0.6    uuid_0.1-2        pkgload_1.0.2     jsonlite_1.6     
[13] memoise_1.1.0     rlang_0.4.2       cli_2.0.0         rstudioapi_0.10   commonmark_1.7    curl_4.3         
[19] yaml_2.2.0        xfun_0.11         withr_2.1.2       stringr_1.4.0     knitr_1.26        fs_1.3.1         
[25] desc_1.2.0        devtools_2.2.1    rprojroot_1.3-2   glue_1.3.1        R6_2.4.1          processx_3.4.1   
[31] fansi_0.4.0       sessioninfo_1.1.1 callr_3.4.0       magrittr_1.5      usethis_1.5.1     backports_1.1.5  
[37] ps_1.3.0          ellipsis_0.3.0    htmltools_0.4.0   assertthat_0.2.1  stringi_1.4.3     crayon_1.3.4   
Run Code Online (Sandbox Code Playgroud)

FvD*_*FvD 0

这看起来与我尝试使用 SendGrid 作为 SMTP 服务时收到的错误相同。问题不在于囊胚,而在于我没有验证“单一发件人身份”。

在 SendGrid UI 中,您将在设置下找到“发件人身份验证”。验证您将用作from囊胚消息中的地址的地址。单击收件箱中收到的验证电子邮件后,从blastula再次发送。现在应该可以毫无问题地传送消息了。