authinfoの設定
Kohkichi Hosoda <[email protected]> Sun, 29 Jan 2012 19:26:20 +0900
| Newsgroups | gmane.emacs.gnus.semi.japanese |
|---|---|
| Message-ID | <[email protected]> |
ものすごーく久しぶりにメールいたします..細田と申します.長文をお許しく
ださい.
職場の環境のせいで,メインのメーラーをthunderbirdとせざるをえず,ここ数年
間はほとんどgnusの設定を弄らないまま過ごしていました.最近,iPhoneのフィ
ルター機能のなさに嫌気がさして,転送してGmailのフィルターを使うようになり,
ふと,それなら,各種のメーラーを全部gnusに統合すれば良いかなと思い始めま
した.org-mode(便利ですねぇ)とも連携させられそうで,こりゃいいわと.
そこで,Emacsとgnusを最新版にしたところ,設定が古すぎるのか,色々と不都合
が出てきて,色々と弄って何とか動くようにはできました.しかし,いくつか疑
問があり,今回,こちらにお尋ねすることにしました.以下に,問題点を列挙し
ます.
1.mail-sourcesの設定
従来の設定は,以下の通りでした.
(setq mail-sources
'((pop :server "hoge.hoge.ne.jp"
:user "[email protected]"
:port "pop3"
:password "secret")))
pw-from-authinfoなんてのも使ってたのですが,動かないですね.パスワードを
書くのが嫌で,ちょっと調べて現在の設定は,以下の通りです.
(setq auth-sources '("~/.authinfo.gpg"))
(setq auth-source-debug 'trivia)
(setq mail-sources
'((pop :server "hoge.hoge.ne.jp"
:user "[email protected]"
:port "pop3")))
.authinfo.gpgには
machine pop.hoge.ne.jp login [email protected] password secret port pop3
machine smtp.hoge.ne.jp login [email protected] password secret port 587
と書いて,gpgで暗号化しています.最初に1回パスフレーズを訊かれますが,
後は訊かれません. Auth-sourceのinfoを読むと,
(setq auth-sources '("~/.authinfo.gpg"))
だけで良さそうな気がしたのですが,後半のパスワード以外の情報を書かないと
ダメです.必要な情報はすべて.authinfo.gpgに入っているのになと不満です.そ
ういうものなのでしょうか?
2.メールの送信設定
こちらも以下のような設定を試したのですが,
(require 'smtpmail)
(setq message-send-mail-function 'message-smtpmail-send-it)
(add-hook 'message-send-mail-hook 'mail-source-touch-pop)
(setq smtpmail-local-domain "hoge.ne.jp")
(setq smtpmail-sendto-domain "hoge.ne.jp")
(setq smtpmail-debug-info t) ; only to debug problems
そうすると,
Sending...
Sending via mail...
auth-source-search: found 1 CACHED results matching (:port "pop3" :user "[email protected]" :host "hoge.hoge.ne.jp" :max 1)
auth-source-search: found 1 backends matching (:host "smtp.hoge.ne.jp" :port "smtp" :user nil :max 1 :require nil :create nil)
auth-source-netrc-parse: using CACHED file data for ~/.authinfo.gpg
auth-source-search: found 0 results (max 1) matching (:host "smtp.hoge.ne.jp" :port "smtp" :user nil :max 1 :require nil :create nil)
550 5.7.1 <[email protected]>... Authentication required.
221 2.0.0 smtp10.dti.ne.jp closing connection
Entering debugger...
となって,うまく認証されず,デバッガーに落ちます.
Debugger entered--Lisp error: (error "Sending failed: 550 5.7.1 <[email protected]>... Authentication required.")
signal(error ("Sending failed: 550 5.7.1 <[email protected]>... Authentication required."))
error("Sending failed: %s" "550 5.7.1 <[email protected]>... Authentication required.")
smtpmail-send-it()
message-smtpmail-send-it()
#[nil " \207" [message-send-mail-function] 1]()
gnus-agent-send-mail()
message-send-mail(nil)
message-send-via-mail(nil)
message-send(nil)
message-send-and-exit(nil)
call-interactively(message-send-and-exit nil nil)
下の様に設定に矢印の部分を追加するとうまくいきます.
(require 'smtpmail)
(setq message-send-mail-function 'message-smtpmail-send-it)
(add-hook 'message-send-mail-hook 'mail-source-touch-pop)
--> (setq smtpmail-smtp-server "smtp.hoge.ne.jp")
--> (setq smtpmail-smtp-service 587)
(setq smtpmail-local-domain "venus.dti.ne.jp")
(setq smtpmail-sendto-domain "venus.dti.ne.jp")
(setq smtpmail-debug-info t) ; only to debug problems
これも必要な情報は,.authinfo.gpgにあるはずなのに,明示的にsmtp serverと
portを指示する必要があるみたいです.これもこういうものなのでしょうか?
もっとスマートな方法があればご教示ください.
よろしくお願いいたします.
なお,うまく行ったときのメッセージは以下の通りです.
Sending...
Sending via mail...
auth-source-search: found 1 CACHED results matching (:port "pop3" :user "[email protected]" :host "hoge.hoge.ne.jp" :max 1)
auth-source-search: found 1 backends matching (:host "smtp.hoge.ne.jp" :port "587" :user nil :max 1 :require nil :create nil)
auth-source-netrc-parse: using CACHED file data for ~/.authinfo.gpg
auth-source-search-backend: got 1 (max 1) in netrc:~/.authinfo.gpg matching (:host "smtp.hoge.ne.jp" :port "587" :user nil :max 1 :require nil :create nil)
auth-source-search: found 1 results (max 1) matching (:host "smtp.hoge.ne.jp" :port "587" :user nil :max 1 :require nil :create nil)
334 PDQwMjUzMzAzMjIuMjQyNDIjhguytfvkjSDDWhr4MkBzbXRwMTIuZHRpLm5lLmpwPg==
235 2.0.0 OK Authenticated
250 2.1.0 <[email protected]>... Sender ok
250 2.1.5 <[email protected]>... Recipient ok
354 Enter mail, end with "." on a line by itself
Sending email
Sending email done
250 2.0.0 q0T84Reh015886 Message accepted for delivery
221 2.0.0 smtp12.dti.ne.jp closing connection
Wrote /Users/kohkichi/Mail/kohkichi/20366
Sending...done