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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {
sb.write_string('Content-Type: text/html; charset=UTF-8')
sb.write_string('Content-Type: text/html; charset=UTF-8\r\n')
} 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(cfg.body)
sb.write_string(base64.encode_str(cfg.body))
sb.write_string('\r\n.\r\n')
c.send_str(sb.str())?
c.expect_reply(.action_ok)?

View File

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