0

We have a ksh script that gets executed daily. It does it function properly however the mail portion does not reflect the subject of the email.

The line of code which executes the mail command is shown below:

mail -s "[Notification]: Success (Date:$batchdate)" `cat $recipients` < $mail_file

Our logs show that the variables batchdate, recipients, and mail_file gets resolved correctly. Now I'm not sure why the subject doesn't show. Is there a different syntax for mail to reflect the subject?

mtryingtocode
  • 939
  • 3
  • 13
  • 26
  • What exactly do you mean by "the subject doesn't show"? What argument is actually being passed to the `mail` command? – Keith Thompson Jan 18 '18 at 01:54
  • The mail we receive shows "(no subject)" instead of the value passed in the command which is "[Notification]: Success (Date:$batchdate)" – mtryingtocode Jan 18 '18 at 02:10
  • 1
    Try changing `mail` to `echo mail` and see what output you get. Is this running from a cron job? How did you verify that the variables are set correctly? – Keith Thompson Jan 18 '18 at 03:32
  • let me try that one out. the script is being executed through Autosys. I have a logfile where I echo the values of the variables. The log doesn't show any error when the mail command gets executed as well. – mtryingtocode Jan 18 '18 at 04:27
  • I tried the following methods and all still give me a blank subject when I receive the email: ``mail -s "[SA Notification]: Email Test 1(Rundate:$rundate)" myemail.com < $mail_file`` ``cat $mail_file | mail -s "Email Test 3(Rundate:$rundate)" myemail.com`` ``echo "`cat $mail_file`" | mail -s "Email Test 2(Rundate:$rundate)" myemail.com`` – mtryingtocode Jan 23 '18 at 01:38
  • 1
    Did you try changing `mail` to `echo mail` as I suggested? That would let you see exactly what arguments are being passed to the `mail` command, and would help narrow down the problem. – Keith Thompson Jan 23 '18 at 02:32
  • Came across this thread https://stackoverflow.com/questions/11889526/subject-name-not-showing-in-my-email-using-mail-command. I didn't know the client was using a Solaris box. I used mailx and managed to make it work properly. – mtryingtocode Feb 05 '18 at 09:28
  • Possible duplicate of [Subject Name not showing in my email using mail command](https://stackoverflow.com/questions/11889526/subject-name-not-showing-in-my-email-using-mail-command) – Keith Thompson Feb 05 '18 at 17:05

0 Answers0