开发者

Send mail via Command-Line and GMail

开发者 https://www.devze.com 2023-01-24 04:38 出处:网络
I\'d like to make a rough framework for a BASH-script which sends me a E-Mail to my GMail account from the same account if a programm exits with non-zero result

I'd like to make a rough framework for a BASH-script which sends me a E-Mail to my GMail account from the same account if a programm exits with non-zero result

test "script to execute"
then
//Send me a mail with the content of /worked.txt
else
//Send me a mail with the content of /failed.txt
fi

I've read it's like this

mail mymail@gmail.com < /worked.txt

it does...nothing No E-Mail, no error, no nothing

-v now says:

> foobar@gmail.com... Connecting to [127.0.0.1] via relay... 220
> my-laptop.lan ESMTP Sendmail
> 8.14.3/8.14.3/Debian-9.1ubuntu1; Wed, 10 Nov 2010 18:34:49 +0100; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
> >>> EHLO my-laptop.lan 250-my-laptop.lan Hello localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN
> 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5
> CRAM-MD5 250-DELIVERBY 250 HELP
> >>> VERB 250 2.0.0 Verbose mode
> >>> MAIL From:<foobar@my-laptop.lan> SIZE=220 AUTH=foobar@my-laptop.lan 250 2.1.0 <foobar@my-laptop.lan>... Sender
> ok
> >>> RCPT To:<foobar@gmail.com>
> >>> DATA 250 2.1.5 <foobar@gmail.com>... Recipient ok 354 Enter mail, end with "." on a line by itself
> >>> . 050 <foobar@gmail.com>... Connecting to gmail-smtp-in.l.google.com. via esmtp... 050 220 mx.google.com ESMTP
&开发者_高级运维gt; c6si1047453fat.137 050 >>> EHLO my-laptop.lan 050 250-mx.google.com at
> your service, [188.19.112.229] 050 250-SIZE 35651584 050 250-8BITMIME
> 050 250 ENHANCEDSTATUSCODES 050 >>> MAIL From:<foobar@my-laptop.lan>
> SIZE=481 050 250 2.1.0 OK c6si1047453fat.137 050 >>> RCPT
> To:<foobar@gmail.com> 050 250
> 2.1.5 OK c6si1047453fat.137 050 >>> DATA 050 354  Go ahead c6si1047453fat.137 050 >>> . 050 250
> 2.0.0 OK 1289410490 c6si1047453fat.137 050 <foobar@gmail.com>... Sent (OK 1289410490 c6si1047453fat.137) 250 2.0.0 oAAHYn4X005767 Message
> accepted for delivery foobar@gmail.com... Sent (oAAHYn4X005767 Message
> accepted for delivery) Closing connection to [127.0.0.1]
> >>> QUIT 221 2.0.0 my-laptop.lan closing connection


I agree with Alex. This should work. Have you checked your SPAM folder on the GMail account? Perhaps it arrived but was automatically classified as junk mail.

-mark

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号