LoginSignup
1
3

More than 5 years have passed since last update.

毎回調べちゃうssmtp->gmailの設定コマンドメモ

Last updated at Posted at 2018-04-17

:pensive:心の声(気楽にメール送信したいよー。開発用なんだよー、特に難しいことしたくないんだよー)

はい、ssmtpどうぞ:angel::point_up:
※CentOS6系前提

#入ってなかったsendmail 
$ yum install -y sendmail
$ service sendmail start

#epelレポ追加
$ yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

#ssmtpインスコ
$ yum -y install --enablerepo=epel ssmtp

#ssmtpせってー
$ vim /etc/ssmtp/ssmtp.conf 
#ここから####################
root=[Gアカウント]@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
hostname=gmail.com
AuthUser=[Gアカウント]@gmail.com
AuthPass=[Gアカウントのパスワード ""とかで囲まなくてok]
AuthMethod=LOGIN
UseSTARTTLS=YES
FromLineOverride=YES
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt #ココめっちゃ!大事!!毎回!!!忘れる!!!!
#ここまで####################

#既定のMTAせってー
$ alternatives --config mta
#There are 2 programs which provide 'mta'.

#  Selection    Command
#-----------------------------------------------
#*+ 1           /usr/sbin/sendmail.sendmail
#   2           /usr/sbin/sendmail.ssmtp

#Enter to keep the current selection[+], or type selection number: 
2 #ssmtpが使いたいから2って入力する

#わいはphp使いだからsendmailのせってーしとかないと
$ vim /etc/php.ini
#上記alternativesコマンドで表示されてたパスを追記か変更か。
# sendmail_path = "/usr/sbin/sendmail -t"
$ service httpd graceful

# 多分、これで終わり.メール送信できるはず!

$ sendmail hogehoge@hogehoge.hoge
To: hogehoge@hogehoge.hoge
From: from@hogehoge.hoge
Subject: Subject is here.

This is Testmail.
.

※場合によっちゃ、外から逆引きできないサーバってんで、gmailからリレー拒否される場合も。
そんな時は、自分のgmailアカウントを「安全性の低いアプリの許可」をしちゃう。
この設定に一切の責任は取りません
https://myaccount.google.com/lesssecureapps

1
3
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
1
3