4

メッセージの FROM に基づいて送信 SMTP を変更するなど、GNU と複数の電子メール アドレスを使用しています。ここまでは順調ですね。ただし、現在、同じサーバーに複数のアカウントがあるため、通常の .authinfo は機能しません。答えはhttp://www.cataclysmicmutation.com/2010/11/multiple-gmail-accounts-in-gnus/に似ているはず ですが、私は gmail を使用しておらず、imap も使用していません。SMTP と SSL を使用しています。そのソリューションを拡張するにはどうすればよいですか? (また: 私は gnus-posting-styles を使用して、適切なアドレスでメールを送信できるようにしています。

以下は、私の .gnus の関連部分です。[ME]@[ME].com (両方とも同じサーバー) に加えて、webdev@[ME].com を機能させようとしていることに注意してください。これを機能させるには、ここと認証情報に何が必要ですか?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; multiple outgoing accounts ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-using-gnus-to.html
;; also see ~/.authinfo
(defvar smtp-accounts
  '(
    (ssl "[ME]@[ME].com" "mail.[ME].com"
     26 "[ME]@[ME].com" secret)
    ;; (ssl "webdev@[ME].com" "mail.[ME].com"
    ;;   26 "webdev@[ME].com" secret)
    (ssl "[ME]@gmail.com" "smtp.gmail.com"
     587 "[ME]@gmail.com" secret)
    (ssl "[ME]@gatech.edu" "mail.gatech.edu"
          587 "[ME]@gatech.edu" secret)
    ))

;; Now lets configure smtpmail.el with your name and functions to send
;; mail using your smtp accounts by changing the from field
(require 'smtpmail)
(setq send-mail-function 'smtpmail-send-it
      message-send-mail-function 'smtpmail-send-it
      mail-from-style nil user-full-name "[ME] S. "
      smtpmail-debug-info t smtpmail-debug-verb t)

(defun set-smtp (mech server port user password)
  "Set related SMTP variables for supplied parameters."
  (setq smtpmail-smtp-server server smtpmail-smtp-service port
    smtpmail-auth-credentials (list (list server port user
                          password)) smtpmail-auth-supported (list mech)
                          smtpmail-starttls-credentials nil)
  (message "Setting SMTP server to `%s:%s' for user `%s'."
       server port user))

(defun set-smtp-ssl (server port user password &optional key
                cert)
  "Set related SMTP and SSL variables for supplied parameters."
  (setq starttls-use-gnutls t
    starttls-gnutls-program "gnutls-cli"
    starttls-extra-arguments nil smtpmail-smtp-server server
    smtpmail-smtp-service port
    smtpmail-auth-credentials (list (list server port user
                          password)) smtpmail-starttls-credentials (list (list
                                                  server port key cert)))
  (message
   "Setting SMTP server to `%s:%s' for user `%s'. (SSL
enabled.)" server port user))

(defun change-smtp ()
  "Change the SMTP server according to the current from line."
  (save-excursion
    (loop with from = (save-restriction
            (message-narrow-to-headers)
            (message-fetch-field "from"))
      for (auth-mech address . auth-spec) in smtp-accounts
      when (string-match address from) do (cond
                           ((memq auth-mech '(cram-md5 plain login))
                        (return (apply 'set-smtp (cons auth-mech auth-spec))))
                           ((eql auth-mech 'ssl)
                        (return (apply 'set-smtp-ssl auth-spec)))
                           (t (error "Unrecognized SMTP auth. mechanism:
`%s'." auth-mech))) finally (error "Cannot infer SMTP information."))))

;; The previous function will complain if you fill the from field with
;; an account not present in smtp-accounts.

(defvar %smtpmail-via-smtp (symbol-function 'smtpmail-via-smtp))

(defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
  (with-current-buffer smtpmail-text-buffer
    (change-smtp))
  (funcall (symbol-value '%smtpmail-via-smtp) recipient
       smtpmail-text-buffer))

;; This wraps send mail via smtp mail, to be able to send multiple
;; messages with smtpmail.

;; Reply-to with same address it was sent to
    (setq gnus-posting-styles
      '(((header "to" "[ME]@gmail.com")
         (address "[ME]@gmail.com"))
    ((header "to" "[ME]@gatech.edu")
         (address "[ME]@gatech.edu"))
    ((header "to" "[ME]@[ME].com")
         (address "[ME]@[ME].com"))
    ;; ((header "to" "webdev@[ME].com")
        ;;  (address "webdev@[ME].com"))
    ;; ((header "cc" "webdev@[ME].com")
        ;;  (address "webdev@[ME].com"))
    ((header "cc" "[ME]@[ME].com")
         (address "[ME]@[ME].com"))
    ((header "cc" "[ME]@gatech.edu")
         (address "[ME]@gatech.edu"))
    ((header "cc" "[ME]@gmail.com")
         (address "[ME]@gmail.com"))))

解決

私が探していた答えは下にありました。完全を期すために、/etc/host ファイル、.authinfo、および .gnus を使用して最終結果のソリューションがどのように見えるかを投稿します。

;; excerpt from .gnus
(defvar smtp-accounts
  '(
    (ssl "first@onedomain.com" "mail.onedomain.com"
     26 "first@onedomain.com" secret)
    (ssl "second@onedomain.com" "mail.onedomain2.com" ;; <-- This is the new alias in my /etc/hosts
         26 "username@onedomain.com" secret) ;; <-- Added these two lines
    ))

;; excerpt from .authinfo
machine mail.onedomain.com login username@onedomain.com port 26 password MyPASS
machine mail.onedomain2.com login username@onedomain.com port 26 password "MyOtherPASS"

;; excerpt from /etc/hosts. The IP was obtained by pinging my mail.onedomain.com
69.89.31.60 mail.onedomain2.com onedomain2
4

4 に答える 4

7

message-mode の X-Message-SMTP-Method ヘッダー フィールドも役立つ場合があります。

例:

X-Message-SMTP-Method: smtp smtp.fsf.org 587 other-user

詳しくは:

  1. https://www.gnu.org/software/emacs/manual/html_node/message/Mail-Variables.html
  2. https://www.gnu.org/software/emacs/manual/html_node/gnus/Posting-Styles.html
于 2014-04-03T20:10:03.660 に答える
2

私は同様の設定をしており、gnus で投稿スタイルを使用して複数の電子メール アカウントから選択しています。前述のように、同じホストに異なるエイリアスを定義し、authinfo エントリを作成していました。次のように見えました。

Contents of ~/.authinfo.gpg:
machine imap.gmail-alias1.com login me@hosteddomain.org password pass port 993
machine imap.gmail-alias2.com login me@gmail.com password pass port 993
machine smtp.gmail1.com login me@hosteddomain.org port 587 password
machine smtp.gmail2.com login me@gmail.com port 587 password

Partial contents of /etc/hosts:
# So I can use multiple gmail accounts in authinfo
# should be same address as imap.gmail.com
173.194.70.108 imap.gmail-alias1.com
173.194.70.108 imap.gmail-alias2.com

74.125.136.108 smtp.gmail1.com
74.125.136.108 smtp.gmail2.com

しかし、 postfixを使用してメールを送信することに切り替えました。あなたができることは、適切なそれぞれの場合のアカウント資格情報。これには、 Postfixプログラムをインストールし、ファイル */etc/postfix/sasl_passwd* および */etc/postfix/sender_relay* をセットアップする必要があります。

于 2014-01-10T04:33:10.610 に答える
0

同じメール サーバーに複数の SMTP アカウントがあり、メール アカウントごとに異なる "ドメイン" を持つ hosts ファイル エントリを定義するだけです。

于 2014-01-06T14:41:07.247 に答える
0

より良い解決策は、すべての smtp 認証の詳細を入力し、送信元のユーザー アカウントに~/.authinfo.gpg(再) 設定smtpmail-smtp-userすることだと思います。smtpmail.el は、同じサーバーに複数のエントリがある場合でも、このエントリのパスワードを使用します。からsmtpmail.el:

(defcustom smtpmail-smtp-user nil
  "User name to use when looking up credentials in the authinfo file.
If non-nil, only consider credentials for the specified user."
  :version "24.1"
  :type '(choice (const nil) string)
  :group 'smtpmail)
于 2016-03-27T00:14:37.293 に答える