Re: How can I know if error happens when sending mail?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On Wednesday, June 3 at 05:20 PM, quoth Chengqi(Lars) Song:
>---------code--------
>lars:~$ less .bin/msmtp-wrap
>#! /bin/bash
>
>msmtp $*
>if [ $? != 0 ]
>then
> gxmessage -wrap -fg red -bg black -default okay -center MSMTP: `tail -1
> ~/.getmail/msmtp.log`
>fi
>----------------------
I have a few minor suggestions.
First, you probably don't want to use $*, but you probably want to use
"$@" instead, to preserve any arguments that might have spaces in
them.
Secondly, you don't have to use the $? variable, you can simply do
this:
#!/bin/bash
if ! msmtp "$@" ; then
gxmessage -wrap -fg red -bg black -default okay -center \
MSMTP: `tail -1 ~/.getmail/msmtp.log`
fi
~Kyle
- --
No nation is permitted to live in ignorance with impunity.
-- Thomas Jefferson
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iQIcBAEBCAAGBQJKJpNwAAoJECuveozR/AWe81oP/iZrn4ytub1+DXDtAhM93jLh
ZWOEK2wNZpAOSscM+C3VjwlnQaQHPRCpYHBIVTZz8I0QUqZaKOYoNMMfCP03r5Ao
DAb3tShzoFkB9mXYCepzPdrI6sbyozdj/gkRGDyZjEe9MzDVp6KJo3iuYJXbP4Q4
UNN533HoiI/mXLNxV2x5NVFmqCn8t+kwdV2WqM0Le0+IDgVpVom0F0ZNu2F8dKAY
ncizdYFsBeVjgBuDVjzo6X6OD+uPGyYNZzW6UpiSL9iqEmkrJ40pa0fjC5uv3VvV
SRyh8vfdkGXjMfF4iASnDUxXMBpdLCAVw1F3kn9nviudauyVbor2ythDY8armrNG
v4wtb+TF5FhYaLUC95UpCdUSNX5Q+I+OUmq5UtyLHTx612vw0W9ZsfTci/7+du4t
lHgujaHElAIy2SGMyp6PP1KoSrLp+znTVJBAvW5hv8pV/J0PfaRbV8UZwPNwdWHU
Q3/TsKuApwxi9jPoWTAdyKyd1cYy7aJhpHvSrM2WELURuzQmwyNNpVFgKjB50iWz
RPiFhknBZXvvrPWEmBAQS2XJbjmwGNIak4queg601UsIn+Trgot9gt94hbSFtdlU
DlUWlzUazN7FA4MgYjdZUSd8DXwGUVUR428pFlSF1/ccYkblZp1Z2UXeA59KpdPc
ZDFrJ/3aihKnkX7CBt4h
=Q2YN
-----END PGP SIGNATURE-----