Subject: bug#7589: smtpmail: bad line endings in queued mails on Windows

From: Eli Zaretskii <[email-masked]>
Date: Sat, 11 Dec 2010 12:07:39 +0200

> Date: Sat, 11 Dec 2010 10:43:47 +0100
> From: Vida Gábor <[email-masked]>
> Cc: [email-masked]
> 
> smtpmail-code-conv-from is nil and the return value of
> (coding-system-change-eol-conversion ...) is also nil right after the
> function call of (set-buffer-file-coding-system ...) that you modified
> in your patch.

Sorry, missed that use-case.  How about the patch below?  (It is
relative to the original version of smtpmail.el.)

=== modified file 'lisp/mail/smtpmail.el'
--- lisp/mail/smtpmail.el	2010-12-09 01:46:03 +0000
+++ lisp/mail/smtpmail.el	2010-12-11 10:03:04 +0000
@@ -392,7 +392,14 @@ The list is in preference order.")
 		(make-directory smtpmail-queue-dir t))
 	      (with-current-buffer buffer-data
 		(erase-buffer)
-		(set-buffer-file-coding-system smtpmail-code-conv-from nil t)
+		(set-buffer-file-coding-system
+		 ;; We will be reading the file with no-conversion in
+		 ;; smtpmail-send-queued-mail below, so write it out
+		 ;; with Unix EOLs.
+		 (coding-system-change-eol-conversion
+		  (or smtpmail-code-conv-from 'undecided)
+		  'unix)
+		 nil t)
 		(insert-buffer-substring tembuf)
 		(write-file file-data)
 		(set-buffer buffer-elisp)