comparison lisp/mail/smtpmail.el @ 88123:375f2633d815

New directory
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Sep 2003 11:56:09 +0000
parents 695cf19ef79e
children 68c22ea6027c
comparison
equal deleted inserted replaced
52428:27bc8b966642 88123:375f2633d815
210 ;;; 210 ;;;
211 ;;; 211 ;;;
212 ;;; 212 ;;;
213 213
214 (defvar smtpmail-mail-address nil 214 (defvar smtpmail-mail-address nil
215 "Value to use for envelope-from address for mail from ambient buffer.") 215 "Value of `user-mail-address' in ambient buffer.")
216 216
217 ;;;###autoload 217 ;;;###autoload
218 (defun smtpmail-send-it () 218 (defun smtpmail-send-it ()
219 (let ((errbuf (if mail-interactive 219 (let ((errbuf (if mail-interactive
220 (generate-new-buffer " smtpmail errors") 220 (generate-new-buffer " smtpmail errors")
221 0)) 221 0))
222 (tembuf (generate-new-buffer " smtpmail temp")) 222 (tembuf (generate-new-buffer " smtpmail temp"))
223 (case-fold-search nil) 223 (case-fold-search nil)
224 delimline 224 delimline
225 (mailbuf (current-buffer)) 225 (mailbuf (current-buffer))
226 ;; Examine this variable now, so that 226 (smtpmail-mail-address user-mail-address)
227 ;; local binding in the mail buffer will take effect.
228 (smtpmail-mail-address
229 (or (and mail-specify-envelope-from (mail-envelope-from))
230 user-mail-address))
231 (smtpmail-code-conv-from 227 (smtpmail-code-conv-from
232 (if enable-multibyte-characters 228 (if enable-multibyte-characters
233 (let ((sendmail-coding-system smtpmail-code-conv-from)) 229 (let ((sendmail-coding-system smtpmail-code-conv-from))
234 (select-message-coding-system))))) 230 (select-message-coding-system)))))
235 (unwind-protect 231 (unwind-protect
401 ;; the MIME headers, and code conversions might guess the 397 ;; the MIME headers, and code conversions might guess the
402 ;; encoding wrongly. 398 ;; encoding wrongly.
403 (with-temp-buffer 399 (with-temp-buffer
404 (let ((coding-system-for-read 'no-conversion)) 400 (let ((coding-system-for-read 'no-conversion))
405 (insert-file-contents file-msg)) 401 (insert-file-contents file-msg))
406 (let ((smtpmail-mail-address 402 (if (not (null smtpmail-recipient-address-list))
407 (or (and mail-specify-envelope-from (mail-envelope-from)) 403 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list
408 user-mail-address))) 404 (current-buffer)))
409 (if (not (null smtpmail-recipient-address-list)) 405 (error "Sending failed; SMTP protocol error"))
410 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list 406 (error "Sending failed; no recipients")))
411 (current-buffer)))
412 (error "Sending failed; SMTP protocol error"))
413 (error "Sending failed; no recipients"))))
414 (delete-file file-msg) 407 (delete-file file-msg)
415 (delete-file (concat file-msg ".el")) 408 (delete-file (concat file-msg ".el"))
416 (delete-region (point-at-bol) (point-at-bol 2))) 409 (delete-region (point-at-bol) (point-at-bol 2)))
417 (write-region (point-min) (point-max) smtpmail-queue-index)))) 410 (write-region (point-min) (point-max) smtpmail-queue-index))))
418 411
550 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer) 543 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
551 (let ((process nil) 544 (let ((process nil)
552 (host (or smtpmail-smtp-server 545 (host (or smtpmail-smtp-server
553 (error "`smtpmail-smtp-server' not defined"))) 546 (error "`smtpmail-smtp-server' not defined")))
554 (port smtpmail-smtp-service) 547 (port smtpmail-smtp-service)
555 ;; smtpmail-mail-address should be set to the appropriate 548 (envelope-from (or (mail-envelope-from)
556 ;; buffer-local value by the caller, but in case not: 549 smtpmail-mail-address
557 (envelope-from (or smtpmail-mail-address 550 user-mail-address))
558 (and mail-specify-envelope-from
559 (mail-envelope-from))
560 user-mail-address))
561 response-code 551 response-code
562 greeting 552 greeting
563 process-buffer 553 process-buffer
564 (supported-extensions '())) 554 (supported-extensions '()))
565 (unwind-protect 555 (unwind-protect
705 " BODY=8BITMIME" 695 " BODY=8BITMIME"
706 "") 696 "")
707 ""))) 697 "")))
708 ; (smtpmail-send-command process (format "MAIL FROM:%s@%s" (user-login-name) (smtpmail-fqdn))) 698 ; (smtpmail-send-command process (format "MAIL FROM:%s@%s" (user-login-name) (smtpmail-fqdn)))
709 (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s" 699 (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s"
710 envelope-from 700 envelope-from
711 size-part 701 size-part
712 body-part)) 702 body-part))
713 703
714 (if (or (null (car (setq response-code (smtpmail-read-response process)))) 704 (if (or (null (car (setq response-code (smtpmail-read-response process))))
715 (not (integerp (car response-code))) 705 (not (integerp (car response-code)))
958 (replace-match "")))))) 948 (replace-match ""))))))
959 949
960 950
961 (provide 'smtpmail) 951 (provide 'smtpmail)
962 952
963 ;;; arch-tag: a76992df-6d71-43b7-9e72-4bacc6c05466
964 ;;; smtpmail.el ends here 953 ;;; smtpmail.el ends here