Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-UTF-8 subject in smtp_send() results in malformed email subject #241

Closed
shrektan opened this issue Dec 1, 2020 · 5 comments · Fixed by #242
Closed

non-UTF-8 subject in smtp_send() results in malformed email subject #241

shrektan opened this issue Dec 1, 2020 · 5 comments · Fixed by #242

Comments

@shrektan
Copy link
Contributor

shrektan commented Dec 1, 2020

On Windows, if the subject argument of smtp_send() is not UTF-8 encoded, the received email's subject will become garbage letters.

However, after I add enc2utf8() on the subject value, the received email becomes expected.

Example

smtp_send(subject = "中文")  # I have to provide `enc2utf8("中文")` as a workaround

The malformed subject

image

Use enc2utf8()

image

@chuxinyuan
Copy link

chuxinyuan commented Dec 19, 2021

我这边即使是用了enc2utf8()函数依然会给出警告信息:

Warning message:
In sprintf("=?utf-8?B?%s?=", base64enc::base64encode(charToRaw(str)),  :
  one argument not used by format '=?utf-8?B?%s?='
xfun::session_info("blastula")
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#> 
#> Locale:
#>   LC_CTYPE=zh_CN.UTF-8       LC_NUMERIC=C              
#>   LC_TIME=zh_CN.UTF-8        LC_COLLATE=zh_CN.UTF-8    
#>   LC_MONETARY=zh_CN.UTF-8    LC_MESSAGES=zh_CN.UTF-8   
#>   LC_PAPER=zh_CN.UTF-8       LC_NAME=C                 
#>   LC_ADDRESS=C               LC_TELEPHONE=C            
#>   LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C       
#> 
#> Package version:
#>   askpass_1.1      base64enc_0.1.3  blastula_0.3.2   cli_3.1.0       
#>   commonmark_1.7   crayon_1.4.2     curl_4.3.2       digest_0.6.28   
#>   dplyr_1.0.7      ellipsis_0.3.2   evaluate_0.14    fansi_0.5.0     
#>   fastmap_1.1.0    fs_1.5.0         generics_0.1.1   getPass_0.2.2   
#>   glue_1.5.0       graphics_4.1.2   grDevices_4.1.2  here_1.0.1      
#>   highr_0.9        htmltools_0.5.2  httr_1.4.2       jquerylib_0.1.4 
#>   jsonlite_1.7.2   knitr_1.36       lifecycle_1.0.1  magrittr_2.0.1  
#>   methods_4.1.2    mime_0.12        openssl_1.4.5    pillar_1.6.4    
#>   pkgconfig_2.0.3  purrr_0.3.4      R6_2.5.1         rlang_0.4.12    
#>   rmarkdown_2.11   rprojroot_2.0.2  rstudioapi_0.13  stats_4.1.2     
#>   stringi_1.7.5    stringr_1.4.0    sys_3.4          tibble_3.1.6    
#>   tidyselect_1.1.1 tinytex_0.35     tools_4.1.2      utf8_1.2.2      
#>   utils_4.1.2      uuid_1.0.3       vctrs_0.3.8      xfun_0.28       
#>   yaml_2.2.1

Created on 2021-12-20 by the reprex package (v2.0.1)

@shrektan
Copy link
Contributor Author

Your issue should have nothing to do with mine, as you are using Ubuntu where the native encoding is UTF-8, unlike Windows.

@chuxinyuan
Copy link

Your issue should have nothing to do with mine, as you are using Ubuntu where the native encoding is UTF-8, unlike Windows.

因为我用的双系统,我要保证在Win和Ubuntu下都能运行,所以还是保留了enc2utf8()以防万一。我现在对mine.R里面的一行代码感到困惑:

str <- sprintf("=?utf-8?B?%s?=", base64enc::base64encode(charToRaw(str)), 0)

每次都是这行代码报警示信息。

@chuxinyuan
Copy link

这个问题很久都没人解决了。

@chuxinyuan
Copy link

The email message was sent successfully.
Warning message:
In sprintf("=?utf-8?B?%s?=", base64enc::base64encode(charToRaw(str)),  :
  one argument not used by format '=?utf-8?B?%s?='

@rich-iannone @shrektan I don't know how to eliminate this prompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants