通过命令行和GMail发送邮件

时间:2010-11-10 17:23:27

标签: email command-line

我想为BASH脚本制作一个粗略的框架,如果程序以非零结果退出,它会从同一帐户向我的GMail帐户发送电子邮件

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

我读过它就像这样

mail mymail@gmail.com < /worked.txt

它确实......没有 没有电子邮件,没有错误,没有任何东西

-v现在说:

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

1 个答案:

答案 0 :(得分:0)

我同意Alex的观点。这应该工作。您是否在GMail帐户上查看了垃圾邮件文件夹?也许它到了,但被自动归类为垃圾邮件。

-mark