Commits

Anonymous committed 83ffd92

Fix mule issue in smtpmail, inform user of Mule issues if we can't solve them

  • Participants
  • Parent commits 3240add

Comments (0)

Files changed (4)

+2000-11-26  Simon Josefsson  <sj@extundo.com>
+
+	* mail-utils.el (mail-y-or-n-p, mail-flatten-list)
+	(mail-check-safe-charset): New functions, from LMI's message.el.
+
+	* smtpmail.el (smtpmail-send-it): Use it; check for bad
+	characters.
+
+	* sendmail.el (sendmail-send-it): Use it; check for bad
+	characters.
+
+2000-11-18  Simon Josefsson  <sj@extundo.com>
+
+	* smtpmail.el (smtpmail-via-smtp): Use `set-process-coding-system'
+	instead of `set-buffer-process-coding-system'.  Only use it if
+	`mule' or `file-coding' is provided.
+	(smtpmail-send-data-1): Call `encode-coding-string' only if `mule'
+	or `file-coding' is provided.
+
 2000-06-26  Charles G Waldman  <cgw@alum.mit.edu>
  
         * mail-abbrevs.el: Remove v18 compatibility code.

File mail-utils.el

 	    (substring s (match-beginning 3) (match-end 3)) " "
 	    (mail-rfc822-time-zone time))))
 
+(defun mail-y-or-n-p (question &rest text)
+  "Ask QUESTION, displaying the rest of the arguments as strings in a buffer."
+  (setq text (mail-flatten-list text))
+  (save-window-excursion
+    (save-excursion
+      (with-output-to-temp-buffer " *SMTP information message*"
+	(set-buffer " *SMTP information message*")
+	(fundamental-mode)		; for Emacs 20.4+
+	(mapcar 'princ text)
+	(goto-char (point-min))))
+    (y-or-n-p question)))
+
+(defun mail-flatten-list (list)
+  "Return a new, flat list that contains all elements of LIST.
+
+\(mail-flatten-list '(1 (2 3 (4 5 (6))) 7))
+=> (1 2 3 4 5 6 7)"
+  (cond ((consp list)
+	 (apply 'append (mapcar 'mail-flatten-list list)))
+	(list
+	 (list list))))
+
+(defun mail-check-safe-charset ()
+  "Check that buffer contain characters that will be safely encoded."
+  (if (featurep 'mule)
+      (let ((bad-charsets (set-difference
+			   (find-charset-region (point-min) (point-max))
+			   '(ascii latin-iso8859-1 control-1))))
+	(when bad-charsets
+	  (or (mail-y-or-n-p 
+	       "Your message contain invalid characters. Continue? "
+	       "You're trying to send a message that contain characters\nin the following character set:\n\n" (mapconcat 'symbol-name bad-charsets ", ") "\n\nThese characters cannot be send without proper encoding.  Please\nconsider using a MIME enabled mail composer (such as `message').\nContinuing is likely to cause mail corruption.")
+	      (error "Message contain invalid character"))))))
+
 (provide 'mail-utils)
 
 ;;; mail-utils.el ends here
 		(save-excursion
 		  (set-buffer errbuf)
 		  (erase-buffer))))
+
+	  ;; XEmacs change
+	  (mail-check-safe-charset)
+
 	  (let ((default-directory "/")
 		exit-value)
 	    (setq exit-value (apply 'call-process-region
 		(smtpmail-deduce-address-list tembuf (point-min) delimline))
 	  (kill-buffer smtpmail-address-buffer)
 
+	  ;; XEmacs change
+	  (mail-check-safe-charset)
+
 	  (smtpmail-do-bcc delimline)
 	  ; Send or queue
 	  (if (not smtpmail-queue-mail)
 
 	  (save-excursion
 	    (set-buffer process-buffer)
-	    (set-buffer-process-coding-system 'no-conversion-unix 'no-conversion-unix)
+	    ;; XEmacs change
+	    (if (or (featurep 'mule) (featurep 'file-coding))
+		(set-process-coding-system process 'no-conversion-unix 'no-conversion-unix))
 	    (make-local-variable 'smtpmail-read-point)
 	    (setq smtpmail-read-point (point-min))
 
   (goto-char (point-max))
 
   ;; XEmacs change
-  (if (and (featurep 'file-coding) (not (null smtpmail-code-conv-from)))
+  (if (and (or (featurep 'mule) (featurep 'file-coding))
+	   (not (null smtpmail-code-conv-from)))
       (setq data (encode-coding-string data smtpmail-code-conv-from)))
 	
   (if smtpmail-debug-info