root@aws:~# apt-get install sendmail Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libperl5.24 libsigsegv2 lockfile-progs m4 make perl perl-modules-5.24 procmail rename sendmail-base sendmail-bin sendmail-cf sensible-mda Suggested packages: m4-doc make-doc perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl sendmail-doc rmail logcheck resolvconf sasl2-bin The following NEW packages will be installed: libperl5.24 libsigsegv2 lockfile-progs m4 make perl perl-modules-5.24 procmail rename sendmail sendmail-base sendmail-bin sendmail-cf sensible-mda 0 upgraded, 14 newly installed, 0 to remove and 1 not upgraded. Need to get 8,950 kB of archives. After this operation, 46.2 MB of additional disk space will be used. Do you want to continue? [Y/n] y : : Creating /etc/mail/sendmail.cf... Creating /etc/mail/submit.cf... Informational: confCR_FILE file empty: /etc/mail/relay-domains Warning: confCT_FILE source file not found: /etc/mail/trusted-users it was created Informational: confCT_FILE file empty: /etc/mail/trusted-users Warning: confCW_FILE source file not found: /etc/mail/local-host-names it was created Warning: access_db source file not found: /etc/mail/access it was created Updating /etc/mail/access... Linking /etc/aliases to /etc/mail/aliases Updating /etc/mail/aliases... /etc/mail/aliases: 12 aliases, longest 10 bytes, 134 bytes total Warning: 3 database(s) sources were not found, (but were created) please investigate. Setting up sensible-mda (8.15.2-8) ... Setting up sendmail (8.15.2-8) ... Processing triggers for systemd (232-25+deb9u1) ... root@aws:~#
root@aws:~# cd /etc/mail root@aws:/etc/mail# mv sendmail.mc{,.orig} root@aws:/etc/mail# cp sendmail.mc{.orig,} root@aws:/etc/mail# vi sendmail.mc root@aws:/etc/mail# diff -u sendmail.mc{.orig,} --- sendmail.mc.orig 2017-12-25 19:27:05.501929251 +0900 +++ sendmail.mc 2017-12-25 19:48:32.113192971 +0900 @@ -54,9 +54,9 @@ dnl # FEATURE(`no_default_msa')dnl dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl -DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl +dnl yasunari DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl -DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl +dnl yasunari DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl dnl # dnl # Be somewhat anal in what we allow define(`confPRIVACY_FLAGS',dnl @@ -97,6 +97,12 @@ include(`/etc/mail/m4/dialup.m4')dnl include(`/etc/mail/m4/provider.m4')dnl dnl # +dnl # Masquerading options +FEATURE(`always_add_domain')dnl +MASQUERADE_AS(`yamasita.jp')dnl +FEATURE(`allmasquerade')dnl +FEATURE(`masquerade_envelope')dnl +dnl # dnl # Default Mailer setup MAILER_DEFINITIONS MAILER(`local')dnl root@cloud:/etc/mail#
oot@aws:/etc/mail# vi local-host-names root@aws:/etc/mail# cat local-host-names localhost aws.yamasita.jp yamasita.jp root@aws:/etc/mail#
root@aws:/etc/mail# /etc/init.d/sendmail restart [ ok ] Restarting sendmail (via systemctl): sendmail.service. root@aws:/etc/mail#相変わらず、systemctl 使えない奴
yasunari@aws:~$ mail -bash: mail: command not found yasunari@aws:~$ Mail -bash: Mail: command not found yasunari@aws:~$mail コマンドがない。
mailutils をインストールする。
yasunari@aws:~$ sudo apt-get install mailutils Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: guile-2.0-libs libfribidi0 libgc1c2 libgsasl7 libkyotocabinet16v5 libltdl7 liblzo2-2 libmailutils5 libmariadbclient18 libntlm0 libpython2.7 mailutils-common mysql-common Suggested packages: mailutils-mh mailutils-doc The following NEW packages will be installed: guile-2.0-libs libfribidi0 libgc1c2 libgsasl7 libkyotocabinet16v5 libltdl7 liblzo2-2 libmailutils5 libmariadbclient18 libntlm0 libpython2.7 mailutils mailutils-common mysql-common 0 upgraded, 14 newly installed, 0 to remove and 1 not upgraded. Need to get 7,344 kB of archives. After this operation, 27.6 MB of additional disk space will be used. Do you want to continue? [Y/n] y : : Setting up mailutils (1:3.1.1-1) ... update-alternatives: using /usr/bin/frm.mailutils to provide /usr/bin/frm (frm) in auto mode update-alternatives: using /usr/bin/from.mailutils to provide /usr/bin/from (from) in auto mode update-alternatives: using /usr/bin/messages.mailutils to provide /usr/bin/messages (messages) in auto mode update-alternatives: using /usr/bin/movemail.mailutils to provide /usr/bin/movemail (movemail) in auto mode update-alternatives: using /usr/bin/readmsg.mailutils to provide /usr/bin/readmsg (readmsg) in auto mode update-alternatives: using /usr/bin/dotlock.mailutils to provide /usr/bin/dotlock (dotlock) in auto mode update-alternatives: using /usr/bin/mail.mailutils to provide /usr/bin/mailx (mailx) in auto mode Processing triggers for libc-bin (2.24-11+deb9u1) ... yasunari@aws:~$
まずはローカル
yasunari@aws:~$ mail yasunari Cc: Subject: test to yasunari test to yasunari yasunari@aws:~$ mail "/var/mail/yasunari": 1 message 1 new >N 1 Yasunari Yamashita Tue Dec 26 15:42 15/623 test to yasunari ? 1 Return-Path: <内緒@yamasita.jp> Received: from aws.yamasita.jp (localhost [127.0.0.1]) by aws.yamasita.jp (8.15.2/8.15.2/Debian-8) with ESMTP id vBQ6gZ4N001426 for <内緒@aws.yamasita.jp>; Tue, 26 Dec 2017 15:42:35 +0900 Received: (from yasunari@localhost) by aws.yamasita.jp (8.15.2/8.15.2/Submit) id vBQ6gZWm001425; Tue, 26 Dec 2017 15:42:35 +0900 Date: Tue, 26 Dec 2017 15:42:35 +0900 From: Yasunari Yamashita <内緒@yamasita.jp> Message-Id: <201712260642.vBQ6gZWm001425@aws.yamasita.jp> To: <内緒@yamasita.jp> Subject: test to yasunari X-Mailer: mail (GNU Mailutils 3.1.1) test to yasunari ? d ? q Held 0 messages in /var/mail/yasunari yasunari@aws:~$ローカル配送OK.
外にも送ってみる
yasunari@aws:~$ mail 内緒@gmail.com Cc: Subject: test to gmail test to gmail yasunari@aws:~$迷惑メールボックスには落ちたが、とりあえず gmail には届いた
← メールサーバの構築(1)AWSへの申請 |
山下康成の 雲の上 |
→ メールサーバの構築(3)ポート開放と対外連携 |
ツイート Tweet to @yasunari_y @yasunari_yをフォロー
Copyright (C) 2003-2018 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市/東京都新宿区