r-lib / gmailr

Access the Gmail RESTful API from R.
https://gmailr.r-lib.org
Other
229 stars 56 forks source link

gm_create_draft and gm_send_message hang #145

Open pschloss opened 3 years ago

pschloss commented 3 years ago

Hi,

I've gotten gmailr to work for me in the past, but am running into a problem now where it hangs when I try to send the emails. I'm creating a bunch of pdf receipts that I attach to an email to send to the people receiving the email. Before I fire everything off, I run your example code. Sometimes the example code works, sometimes it hangs on gm_create_draft and and gm_send_message.

gm_auth_configure(path = "~/credentials.json")
gm_auth(email = TRUE)

test_email <-
  gm_mime() %>%
  gm_to("xxxxxxx@umich.edu") %>%
  gm_from("xxxxxxx@gmail.com") %>%
  gm_subject("this is just a gmailr test") %>%
  gm_text_body("Can you hear me now?")

# Verify it looks correct
gm_create_draft(test_email)
#Error in gmailr_POST("drafts", user_id, class = "gmail_draft", query = list(uploadType = "media"),  : 
# Gmail API error: 408

gm_send_message(test_email)

When I get to my loop where I send out the emails, sometimes it will get through several of the recipients and then hang but mostly it is just hanging and not doing anything. This sounds like #126, but I'm not sure.

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] xtable_1.8-4      rmarkdown_2.3     forcats_0.5.0     stringr_1.4.0    
 [5] dplyr_1.0.2       purrr_0.3.4       readr_1.3.1       tidyr_1.1.2      
 [9] tibble_3.0.3      ggplot2_3.3.2     tidyverse_1.3.0   devtools_2.3.1   
[13] usethis_1.6.1     gmailr_1.0.0.9000

loaded via a namespace (and not attached):
 [1] httr_1.4.2        pkgload_1.1.0     jsonlite_1.7.1    modelr_0.1.8     
 [5] assertthat_0.2.1  askpass_1.1       blob_1.2.1        cellranger_1.1.0 
 [9] yaml_2.2.1        remotes_2.2.0     sessioninfo_1.1.1 pillar_1.4.6     
[13] backports_1.1.9   glue_1.4.2        digest_0.6.25     rvest_0.3.6      
[17] colorspace_1.4-1  htmltools_0.5.0   pkgconfig_2.0.3   broom_0.7.0      
[21] haven_2.3.1       scales_1.1.1      processx_3.4.4    openssl_1.4.3    
[25] generics_0.0.2    ellipsis_0.3.1    withr_2.3.0       cli_2.0.2        
[29] magrittr_1.5      crayon_1.3.4      readxl_1.3.1      mime_0.9         
[33] memoise_1.1.0     evaluate_0.14     ps_1.3.4          fs_1.5.0         
[37] fansi_0.4.1       xml2_1.3.2        pkgbuild_1.1.0    tools_4.0.2      
[41] prettyunits_1.1.1 hms_0.5.3         gargle_0.5.0      lifecycle_0.2.0  
[45] munsell_0.5.0     reprex_0.3.0      callr_3.4.4       compiler_4.0.2   
[49] tinytex_0.25      rlang_0.4.7       grid_4.0.2        rstudioapi_0.11  
[53] base64enc_0.1-3   testthat_2.3.2    gtable_0.3.0      DBI_1.1.0        
[57] curl_4.3          rematch2_2.1.2    R6_2.4.1          lubridate_1.7.9  
[61] knitr_1.29        utf8_1.1.4        rprojroot_1.3-2   desc_1.2.0       
[65] stringi_1.4.6     Rcpp_1.0.5        vctrs_0.3.4       dbplyr_1.4.4     
[69] tidyselect_1.1.0  xfun_0.16        
bomeara commented 3 years ago

I have been encountering #126 as well (sending ~50 emails, each with two attachments). Once I got rid of attachments, the issues seem to have gone away (though of course eliminating attachments won't work for everyone). Same version of R and gmailr as you:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] httpuv_1.5.4        dplyr_1.0.2         googlesheets4_0.2.0
 [4] Hmisc_4.4-1         ggplot2_3.3.2       Formula_1.2-3
 [7] survival_3.2-3      lattice_0.20-41     gmailr_1.0.0.9000
[10] anytime_0.3.8       lubridate_1.7.9

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.0    xfun_0.16           purrr_0.3.4
 [4] gargle_0.5.0        splines_4.0.2       colorspace_1.4-1
 [7] vctrs_0.3.4         generics_0.0.2      htmltools_0.5.0
[10] base64enc_0.1-3     rlang_0.4.7         pillar_1.4.6
[13] later_1.1.0.1       foreign_0.8-80      glue_1.4.2
[16] withr_2.3.0         RColorBrewer_1.1-2  jpeg_0.1-8.1
[19] lifecycle_0.2.0     stringr_1.4.0       munsell_0.5.0
[22] gtable_0.3.0        cellranger_1.1.0    htmlwidgets_1.5.1
[25] latticeExtra_0.6-29 knitr_1.29          curl_4.3
[28] htmlTable_2.0.1     Rcpp_1.0.5          openssl_1.4.3
[31] scales_1.1.1        backports_1.1.9     promises_1.1.1
[34] checkmate_2.0.0     jsonlite_1.7.1      fs_1.5.0
[37] gridExtra_2.3       askpass_1.1         png_0.1-7
[40] digest_0.6.25       stringi_1.4.6       grid_4.0.2
[43] tools_4.0.2         magrittr_1.5        tibble_3.0.3
[46] cluster_2.1.0       crayon_1.3.4        pkgconfig_2.0.3
[49] ellipsis_0.3.1      Matrix_1.2-18       data.table_1.13.0
[52] googledrive_1.0.1   httr_1.4.2          rstudioapi_0.11
[55] R6_2.4.1            rpart_4.1-15        nnet_7.3-14
[58] compiler_4.0.2
pschloss commented 3 years ago

For what it's worth, I seem able to get the test email sent out without issue, but like @bomeara mentioned, if I add a PDF attachment to the email it hangs.