changeset 102909:64294c07cca6

* mail/sendmail.el (sendmail-send-it): Replace any pre-existing Content-type header if we insert one.
author Richard M. Stallman <rms@gnu.org>
date Thu, 09 Apr 2009 16:33:41 +0000
parents 9c4ff2c2c769
children 3d4fe9d9e9e6
files lisp/ChangeLog lisp/mail/sendmail.el
diffstat 2 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Apr 09 13:46:27 2009 +0000
+++ b/lisp/ChangeLog	Thu Apr 09 16:33:41 2009 +0000
@@ -1,3 +1,8 @@
+2009-04-09  Richard M Stallman  <rms@gnu.org>
+
+	* mail/sendmail.el (sendmail-send-it): Replace any
+	pre-existing Content-type header if we insert one.
+
 2009-04-09  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp.el (tramp-file-name-handler-alist): Add
--- a/lisp/mail/sendmail.el	Thu Apr 09 13:46:27 2009 +0000
+++ b/lisp/mail/sendmail.el	Thu Apr 09 16:33:41 2009 +0000
@@ -1113,7 +1113,10 @@
 	    (if (not (re-search-forward "^From:" delimline t))
 		(mail-insert-from-field))
 	    ;; Possibly add a MIME header for the current coding system
-	    (let (charset)
+	    (let (charset where-content-type)
+	      (goto-char (point-min))
+	      (setq where-content-type
+		    (re-search-forward "^Content-type:" delimline t))
 	      (goto-char (point-min))
 	      (and (eq mail-send-nonascii 'mime)
 		   (not (re-search-forward "^MIME-version:" delimline t))
@@ -1122,11 +1125,19 @@
 		   selected-coding
 		   (setq charset
 			 (coding-system-get selected-coding :mime-charset))
-		   (goto-char delimline)
-		   (insert "MIME-version: 1.0\n"
-			   "Content-type: text/plain; charset="
-			   (symbol-name charset)
-			   "\nContent-Transfer-Encoding: 8bit\n")))
+		   (progn
+		     (goto-char delimline)
+		     (insert "MIME-version: 1.0\n"
+			     "Content-type: text/plain; charset="
+			     (symbol-name charset)
+			     "\nContent-Transfer-Encoding: 8bit\n")
+		   ;; The character set we will actually use
+		   ;; should override any specified in the message itself.
+		     (when where-content-type
+		       (goto-char where-content-type)
+		       (beginning-of-line)
+		       (delete-region (point)
+				      (progn (forward-line 1) (point)))))))
 	    ;; Insert an extra newline if we need it to work around
 	    ;; Sun's bug that swallows newlines.
 	    (goto-char (1+ delimline))