SMTP
予めwhalebrewでMailHogがインストールされているものとする。
https://blog.symdon.info/posts/1614485711/
MailHogを起動する。
$ mailhog 2021/02/28 04:45:28 Using in-memory storage 2021/02/28 04:45:28 [SMTP] Binding to address: 0.0.0.0:1025 [HTTP] Binding to address: 0.0.0.0:8025 2021/02/28 04:45:28 Serving under http://0.0.0.0:8025/ Creating API v1 with WebPath: Creating API v2 with WebPath:
EmacsのSMTPの設定を行う。
(setq smtpmail-smtp-server "host.docker.internal")
(setq smtpmail-smtp-service 1025)
(setq send-mail-function #'smtpmail-send-it)
/etc/hostsには以下を設定しておく。
127.0.0.1 host.docker.internal
M-x mail
を実行してメール編集バッファに内容を記述し M-x mail-send-and-exit
(C-c C-c) を実行する。
SMTPでMilHogに対しメールが送信される。
以下はMailHogのログ。
2021/02/28 04:54:54 Using in-memory storage 2021/02/28 04:54:54 [SMTP] Binding to address: 0.0.0.0:1025 [HTTP] Binding to address: 0.0.0.0:8025 2021/02/28 04:54:54 Serving under http://0.0.0.0:8025/ Creating API v1 with WebPath: Creating API v2 with WebPath: 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Starting session 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: INVALID] Started session, switching to ESTABLISH state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 35 bytes: '220 mailhog.example ESMTP MailHog\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Received 16 bytes: 'EHLO ng1.local\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: ESTABLISH] Processing line: EHLO ng1.local 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: ESTABLISH] In state 1, got command 'EHLO', args 'ng1.local' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: ESTABLISH] In ESTABLISH state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: ESTABLISH] Got EHLO command, switching to MAIL state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 21 bytes: '250-Hello ng1.local\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 16 bytes: '250-PIPELINING\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 16 bytes: '250 AUTH PLAIN\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Received 31 bytes: 'MAIL FROM:<[email protected]>\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] Processing line: MAIL FROM:<[email protected]> 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] In state 6, got command 'MAIL', args 'FROM:<[email protected]>' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] In MAIL state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] Got MAIL command, switching to RCPT state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 33 bytes: '250 Sender [email protected] ok\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Received 28 bytes: 'RCPT TO:<[email protected]>\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] Processing line: RCPT TO:<[email protected]> 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] In state 7, got command 'RCPT', args 'TO:<[email protected]>' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] In RCPT state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] Got RCPT command 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 35 bytes: '250 Recipient [email protected] ok\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Received 6 bytes: 'DATA\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] Processing line: DATA 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] In state 7, got command 'DATA', args '' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] In RCPT state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: RCPT] Got DATA command, switching to DATA state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 37 bytes: '354 End data with <CR><LF>.<CR><LF>\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Received 203 bytes: 'Date: Sun, 28 Feb 2021 13:54:57 +0900\r\nMessage-Id: <m21rd0bxlq.fsf@ng1.local.i-did-not-set--mail-host-address--so-tickle-me>\r\nFrom: sximada <[email protected]>\r\nTo: [email protected]\r\nSubject: a\r\n\r\nb\r\n.\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: DATA] Got EOF, storing message and switching to MAIL state 2021/02/28 04:54:57 Parsing Content from string: 'Date: Sun, 28 Feb 2021 13:54:57 +0900 Message-Id: <m21rd0bxlq.fsf@ng1.local.i-did-not-set--mail-host-address--so-tickle-me> From: sximada <[email protected]> To: [email protected] Subject: a b' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Storing message [email protected] 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 80 bytes: '250 Ok: queued as [email protected]\r\n' Got message in APIv2 websocket channel [APIv2] BROADCAST /api/v2/websocket Got message in APIv1 event stream Sending content: { "ID": "[email protected]", "From": { "Relays": null, "Mailbox": "sximada", "Domain": "ng1.local", "Params": "" }, "To": [ { "Relays": null, "Mailbox": "test", "Domain": "example.com", "Params": "" } ], "Content": { "Headers": { "Date": [ "Sun, 28 Feb 2021 13:54:57 +0900" ], "From": [ "sximada \[email protected]\u003e" ], "Message-Id": [ "\u003cm21rd0bxlq.fsf@ng1.local.i-did-not-set--mail-host-address--so-tickle-me\u003e" ], "Received": [ "from ng1.local by mailhog.example (MailHog)\r\n id [email protected]; Sun, 28 Feb 2021 04:54:57 +0000" ], "Return-Path": [ "\[email protected]\u003e" ], "Subject": [ "a" ], "To": [ "[email protected]" ] }, "Body": "b", "Size": 198, "MIME": null }, "Created": "2021-02-28T04:54:57.2706133Z", "MIME": null, "Raw": { "From": "[email protected]", "To": [ "[email protected]" ], "Data": "Date: Sun, 28 Feb 2021 13:54:57 +0900\r\nMessage-Id: \u003cm21rd0bxlq.fsf@ng1.local.i-did-not-set--mail-host-address--so-tickle-me\u003e\r\nFrom: sximada \[email protected]\u003e\r\nTo: [email protected]\r\nSubject: a\r\n\r\nb", "Helo": "ng1.local" } } [APIv1] BROADCAST /api/v1/events 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Received 6 bytes: 'QUIT\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] Processing line: QUIT 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] In state 6, got command 'QUIT', args '' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] [PROTO: MAIL] Got QUIT verb, staying in MAIL state 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Sent 9 bytes: '221 Bye\r\n' 2021/02/28 04:54:57 [SMTP 172.17.0.1:55570] Session ended ^[<^G^C Process *ansi-term*<2> exited abnormally with code 130