LoginSignup
0
0

Sendmail から Postfix へ

Posted at

経緯

結論。
今後は、「後継のPostfixを使え」ということらしい。

自宅開発環境でメールが飛ばないことは知っていたが、面倒臭そうなので放置していた。
が、一念発起し、sendmailまわりの設定を調査。

しかしながら、調べていくうちにsendmailは非推奨になっているということを知った。
今後は、「後継のPostfixを使え」ということらしい。

制限事項

  • 開発環境での使用を前提としています。
  • 本番はこの限りではないと思われます。

構築手順

  1. sendmailを削除
    sudo apt remove sendmail -y
    sudo apt autoremove -y
    
  2. Postfixの設定ファイルを配置
    sudo cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf
    
  3. Postfixの設定ファイルを編集
    diff /usr/share/postfix/main.cf.dist /etc/postfix/main.cf
    82c82
    < #mail_owner = postfix
    ---
    > mail_owner = postfix
    98c98
    < #myhostname = host.domain.tld
    ---
    > myhostname = messiah
    127c127
    < #myorigin = $mydomain
    ---
    > myorigin = $mydomain
    141c141
    < #inet_interfaces = all
    ---
    > inet_interfaces = all
    189c189
    < #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    ---
    > mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    232c232
    < #local_recipient_maps = unix:passwd.byname $alias_maps
    ---
    > local_recipient_maps = unix:passwd.byname $alias_maps
    583c583
    < #smtpd_banner = $myhostname ESMTP $mail_name
    ---
    > smtpd_banner = $myhostname ESMTP
    585c585
    < smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    ---
    > #smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    659c659
    < sendmail_path =
    ---
    > sendmail_path = /usr/sbin/postfix
    664c664
    < newaliases_path =
    ---
    > newaliases_path = /usr/bin/mailq
    669c669
    < mailq_path =
    ---
    > mailq_path = /usr/bin/mailq
    675c675
    < setgid_group =
    ---
    > setgid_group = postdrop
    679c679
    < html_directory =
    ---
    > #html_directory =
    683c683
    < manpage_directory =
    ---
    > #manpage_directory =
    688c688
    < sample_directory =
    ---
    > #sample_directory =
    692c692
    < readme_directory =
    ---
    > #readme_directory =
    693a694,696
    >
    > message_size_limit = 10485760
    > mailbox_size_limit = 1073741824
    
  4. Postfixを再起動
    sudo newaliases
    sudo /etc/init.d/postfix restart
    

動作確認

  • テストメールを送信してみる
    sudo echo -e 'Subject: Hello!\n\nHello!\nWorld' | sendmail -f {fromメールアドレス} {toメールアドレス}
    
    • 送信されたメールが受信できることを確認

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0