aboutsummaryrefslogtreecommitdiffstats
path: root/tools/send-mail.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-03-08 16:23:31 +0000
committerWerner Koch <[email protected]>2017-03-08 16:25:27 +0000
commit5c83759364272b19ceafbef46d057f0430a12698 (patch)
tree1e9bfbb91b6d61d27ce86737e51c0318e4ea6329 /tools/send-mail.c
parentbuild: Use macOS' compatibility macros to enable all features. (diff)
downloadgnupg-5c83759364272b19ceafbef46d057f0430a12698.tar.gz
gnupg-5c83759364272b19ceafbef46d057f0430a12698.zip
wks: Put stdout into binary mode for Windows.
* tools/send-mail.c (send_mail_to_file): Call es_set_binary. -- Without that, output to stdout via --send is mangled: The "\r\n" is translated to "\r\r\n" which is bad because other software (e.g. Thunderbird) translates this again to "\n\n" and thus put all mail header liens after the first into the body. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--tools/send-mail.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/send-mail.c b/tools/send-mail.c
index 34d47c16d..fb1a9d0c9 100644
--- a/tools/send-mail.c
+++ b/tools/send-mail.c
@@ -71,13 +71,23 @@ send_mail_to_file (estream_t fp, const char *fname)
if (!buffer)
return gpg_error_from_syserror ();
- outfp = !strcmp (fname,"-")? es_stdout : es_fopen (fname, "wb");
- if (!outfp)
+
+ if (!strcmp (fname,"-"))
{
- err = gpg_error_from_syserror ();
- log_error ("error creating '%s': %s\n", fname, gpg_strerror (err));
- goto leave;
+ outfp = es_stdout;
+ es_set_binary (es_stdout);
}
+ else
+ {
+ outfp = es_fopen (fname, "wb");
+ if (!outfp)
+ {
+ err = gpg_error_from_syserror ();
+ log_error ("error creating '%s': %s\n", fname, gpg_strerror (err));
+ goto leave;
+ }
+ }
+
for (;;)
{
if (es_read (fp, buffer, sizeof buffer, &nbytes))