3

I am sending mail to a list of users, using the mailx utility:

mailx -s "$SUBJECT" "$TO" < $FILE

It is working fine with valid emails, but I am getting a dead.letter issue when I try to send mail like adffadf, i.e., the string is not a valid email,

I want this dead.letter to not be occurring even for users having anything for email ID, e.g., abc@gmail.com, abc@def.cc, adffdfs

Thomas Dickey
  • 76,765

3 Answers3

5

The man page for mailx says that the DEAD environment variable can be used to override the dead.letter file. Set it to /dev/null and you should get no more dead letters

export DEAD=/dev/null    # sh, bash, ksh, ...
setenv DEAD /dev/null    # csh, tcsh
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • thanks for your response, i just want to skip deat.latter error, even email id is not correct, is there any way to do so? – Girdhar Singh Rathore Aug 04 '15 at 15:36
  • i have set environmenet variable export DEAD=/dev/null but i am still getting dead.latter file – Girdhar Singh Rathore Aug 04 '15 at 16:09
  • 2
    @GirdharSinghRathore please update your question to indicate the OS that you're running on, and the version of mailx. Does the man page for your version of mailx offer the DEAD environment variable? – Chris Davies Aug 04 '15 at 16:30
  • i got below info but i don't know how to set save environment variable save - saves messages in your dead.letter file if they are interrupted while being composed. The name of your dead.letter file is given by the DEAD variable. Setting nosave disables this automatic save feature. The default is save.

    and nosave Normally, when you abort a message with two interrupt characters (usually control-C), mail copies the partial letter to the file dead.letter in your home directory. Setting the binary option nosave prevents this.

    can you please help on this

    – Girdhar Singh Rathore Aug 05 '15 at 11:26
  • 1
    @GirdharSinghRathore you aren't interrupting an interactive session with Ctrl/C so this option won't help you – Chris Davies Aug 07 '15 at 08:33
  • Thanks for your response, i got below answer, that works for me :) – Girdhar Singh Rathore Aug 07 '15 at 08:47
2

The man page for my mailx says a lot of things about set nosave and so on, but they don't seem to work. The only way to stop your dead.letter file growing I have found is to replace it by a link to the special file /dev/null.

rm ~/dead.letter

ln -s /dev/null ~/dead.letter
0

Because sometimes I want to debug with dead.letter, I use:

Makefile...

 mail:
       mailx -vs $(a) -a $(a) email@web.com; \
       rm dead.letter

Command line...

make mail a=file.txt

verbose output prevents needing to press ENTER after; dead.letter deleted or fails silently; no other options seem to work (e.g. -i -e ...)

Jason
  • 103