2017-09-27 1 views
0

私はxubuntu 16.04を使って開発ボックスを持っています。私はメールを処理するためにssmtpをセットアップし、電子メールを送ることができます。私はそれをテストしましたcronのメールが届いていない場所がありません

mail [email protected] < .~/.bashrc' 

それはうまくいきました。私は自分のcronによって送信される出力を生成する毎分実行するcronジョブを持っています。 'グレップCRONは/ var/log/syslogが' 私に

Sep 27 15:22:01 epdev CRON[19569]: (eventpuddle) CMD (cd /home/eventpuddle/eventpuddle/batch; ./scrape_check_todays_logs.bash) 
Sep 27 15:22:01 epdev sSMTP[19571]: Creating SSL connection to host 
Sep 27 15:22:01 epdev sSMTP[19571]: SSL connection using RSA_AES_128_CBC_SHA1 
Sep 27 15:22:03 epdev sSMTP[19571]: Sent mail for [email protected] (221 2.0.0 Bye) uid=1000 username=eventpuddle outbytes=816 

もしI 'はsudo -i' を与え、私はメールがありません言われていたメールを入力します。 /etc/ssmtp/ssmtp.confは次のとおりです。

[email protected] 
mailhub=mail.myhoestingpeople.com:2525 
hostname=sun.prsc 
UseSTARTTLS=YES 
AuthUser=user 
AuthPass=password 
FromLineOverride=YES 
UseTLS=YES 

cront enteryは

* * * * * (cd /home/eventpuddle/eventpuddle/batch; ./scrape_check_todays_logs.bash) 

./scrape_check_todays_logs.bashが

#!/bin/bash 
# scrape_check_todays_logs.bash (c) 2017 Ben Edwards (http://funkytwig.com/it) 
# Check logfiles for today and email them if there are any errors. 

. ~/.bashrc 

[ -z "$HOME" ]  && { echo '$HOME not set'; exit 1; } 
[ -z "$ADMIN_EMAIL" ] && { echo '$ADMIN_EMAIL not set'; exit 1; } 

t=/tmp/`basename $0 .bash`.$$.tmp 
d=$HOME 

grep -l "$d" log/*`date +%A`* > $t 

cat $t | while read line 
do 
    echo "mail $line" 
    mail -s "eventpuddle batch failuure $line" $ADMIN_EMAIL < $line 
done 

grep EXCLUD log/*`date +%A`* > $t 

mail -s 'eventpuddle exclusions' $ADMIN_EMAIL < $t 

ない与えるために、他のどのような情報を確認してくださいしかし、もし意志であります尋ねた

答えて

0

外見では、メールを外部のメールアドレスに転送しようとしているようですが、 SSMTPは、外部電子メールに警告を転送するために使用されます。 SSMTPの設定はありますか?コンフィギュレーション(/etc/ssmtp/ssmtp.conf)は、このよう

# The user that gets all the mails (UID < 1000, usually the admin) 
[email protected] 

# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable 
# See also https://support.google.com/mail/answer/78799 
mailhub=smtp.gmail.com:587 

# The address where the mail appears to come from for user authentication. 
rewriteDomain=gmail.com 

# The full hostname. Must be correctly formed, fully qualified domain name or GMail will reject connection. 
hostname=yourlocalhost.yourlocaldomain.tld 

# Use SSL/TLS before starting negotiation 
UseTLS=Yes 
UseSTARTTLS=Yes 

# Username/Password 
AuthUser=username 
AuthPass=password 
AuthMethod=LOGIN 

# Email 'From header's can override the default domain? 
FromLineOverride=yes 

になりますUbuntuは、それを設定する方法についてはかなり良いドキュメントを持っている - here

+0

私は外部のSMTPサーバーを使用してに送信しています外部の電子メールアドレス。 Iveはいくつかのマシンで単に/ etc/ssmtp/ssmtp.confを使って、単純にcronの出力やその他のものを私に送りました。私がssmtpを使用する理由は、他の多くの人がそれを使用する理由は、ボックスに従来のメールサービスを設定する必要がないからです。私が言ったように、私はメールをうまく送ることができます、それはちょうどそれが動作しないcronからそれを送るので、ssmtpは正しく設定されているようです。 –

+0

あなたのcronの仕事は何ですか?ここに貼り付けられますか? – FELASNIPER

+0

が質問に追加されました –

関連する問題