- (setq tembuf (find-file-noselect file-msg))
- (if (not (null smtpmail-recipient-address-list))
- (if (not (smtpmail-via-smtp smtpmail-recipient-address-list
- tembuf))
- (error "Sending failed; SMTP protocol error"))
- (error "Sending failed; no recipients"))
+ ;; Insert the message literally: it is already encoded as per
+ ;; the MIME headers, and code conversions might guess the
+ ;; encoding wrongly.
+ (with-temp-buffer
+ (let ((coding-system-for-read 'no-conversion))
+ (insert-file-contents file-msg))
+ (let ((smtpmail-mail-address
+ (or (and mail-specify-envelope-from (mail-envelope-from))
+ user-mail-address)))
+ (if (not (null smtpmail-recipient-address-list))
+ (if (not (smtpmail-via-smtp smtpmail-recipient-address-list
+ (current-buffer)))
+ (error "Sending failed; SMTP protocol error"))
+ (error "Sending failed; no recipients"))))