1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

smtp: add base64 encoding to the body of the emails and use utf8, to prevent format confusion (#15589)

This commit is contained in:
shove
2022-08-29 14:19:46 +08:00
committed by GitHub
parent 72056f36d8
commit f285ebd91c
2 changed files with 12 additions and 3 deletions

View File

@ -245,12 +245,13 @@ fn (mut c Client) send_body(cfg Mail) ? {
} }
if is_html { if is_html {
sb.write_string('Content-Type: text/html; charset=UTF-8') sb.write_string('Content-Type: text/html; charset=UTF-8\r\n')
} else { } else {
sb.write_string('Content-Type: text/plain; charset=UTF-8') sb.write_string('Content-Type: text/plain; charset=UTF-8\r\n')
} }
sb.write_string('Content-Transfer-Encoding: base64')
sb.write_string('\r\n\r\n') sb.write_string('\r\n\r\n')
sb.write_string(cfg.body) sb.write_string(base64.encode_str(cfg.body))
sb.write_string('\r\n.\r\n') sb.write_string('\r\n.\r\n')
c.send_str(sb.str())? c.send_str(sb.str())?
c.expect_reply(.action_ok)? c.expect_reply(.action_ok)?

View File

@ -131,3 +131,11 @@ fn test_smtp_multiple_recipients() ? {
assert true assert true
} }
fn test_smtp_body_base64encode() ? {
$if !network ? {
return
}
assert true
}