<<< Date Index >>>     <<< Thread Index >>>

Re: How can I know if error happens when sending mail?



thanks, your suggestion is applied :)
On Wed, 03 Jun 2009, Kyle Wheeler wrote:

> 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