Solved

Email Subject Not Showing

Posted on 2011-09-12
44
553 Views
Last Modified: 2012-05-12
Trying to put together a script to send out email.  I have a SUBJECT=, but the email always arrives saying 'no subject'.  What am I missing?


#!/bin/bash
# script to send simple email
# email subject
SUBJECT="DELETED TODAY"
# Email To ?
EMAIL="cornelius.taylor@csueastbay.edu"
# Email text/message
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
~
~
0
Comment
Question by:xoxomos
  • 17
  • 16
  • 11
44 Comments
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
change
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

Open in new window

to
/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE

Open in new window

0
 

Author Comment

by:xoxomos
Comment Utility
#!/bin/bash
# script to send simple email
# email subject
SUBJECT='DELETED TODAY'
# Email To ?
EMAIL="cornelius.taylor@csueastbay.edu"
# Email text/message
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "Testing email"
/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE


Still saying (no subject) :-(
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 250 total points
Comment Utility
Well,

I can't see any mistake in your script.

Maybe we should try to approach step by step.

What do you get with

/bin/mail -s "DELETED TODAY" "${EMAIL}" < $EMAILMESSAGE

Does it work?

If this doesn't work either - could it be that some server inbetween doesn't like "DELETED"?

Does this work then:

/bin/mail -s "XXXXXXX TODAY" "${EMAIL}" < $EMAILMESSAGE

?

wmp

0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
I heard some people don't like "XXX..." either.

So try something like "EXPERIMENTAL SUBJECT" or the like.
0
 
LVL 21

Assisted Solution

by:Papertrip
Papertrip earned 250 total points
Comment Utility
I tested the updated syntax, with DELETED in the subject, and it worked just fine as I expected.

wmp might be on to something about the contents of the subject... I've never ran across that but it wouldn't surprise me if something like that was indeed happening.

Curious what happens when you change subject per wmp's recommendation.
0
 

Author Comment

by:xoxomos
Comment Utility
Thanks  but same thing :-(
#!/bin/bash
# script to send simple email
# email subject
SUBJECT='DELETED TODAY'
# Email To ?
EMAIL="cornelius.taylor@csueastbay.edu"
# Email text/message
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "Testing email"
#/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE
/bin/mail -s "TODAY" "${EMAIL}" < $EMAILMESSAGE
~

#!/bin/bash
# script to send simple email
# email subject
SUBJECT="EXPERIMENTAL SUBJECT"
# Email To ?
EMAIL="cornelius.taylor@csueastbay.edu"
# Email text/message
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
#/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE
/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE
~


0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
OK so.  These mails you are sending are being received, correct?  Check the headers and look for the "Subject" line -- I'm curious if the header is non-existant, a null value, or if it says "(no subject)" like you posted earlier.

I understand that the "(no subject)" is probably just something displayed by your email client, but look for it in the headers anyways.

Bottom line here is the script works in general.
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
So we have some general problem with the script as a whole.

Could it be that you wrote the script under e.g. Windows and transferred it
(maybe even with copy and paste) to Unix?

Could you try just from the command line (outside any script, that is):

mail -s "MYSUBJECT" cornelius.taylor@csueastbay.edu < /etc/hosts

?
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Bottom line here is the script works in general.
So we have some general problem with the script as a whole.

Haha!

Ok let me rephrase mine -- Bottom line here is the script is syntactically correct :)
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Syntactically - yes!

I'm rather emphasizing some invisible characters or the like.

0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Yep I'm on board with your latest guess :)
0
 

Author Comment

by:xoxomos
Comment Utility
Nothing much header wise

Reply
      from      oracle@bb7b.csueastbay.edu
to      
date      Mon, Sep 12, 2011 at 2:10 PM
mailed-by      bb7b.csueastbay.edu
hide details 2:10 PM (39 minutes ago)
0 rows deleted.

 Reply
 Forward
0
 

Author Comment

by:xoxomos
Comment Utility
Yes i did put it on notepad and copied it to unix but when i set list, it looks ok.

#!/bin/bash$
# script to send simple email$
# email subject$
SUBJECT="EXPERIMENTAL SUBJECT"$
# Email To ?$
EMAIL="cornelius.taylor@csueastbay.edu"$
# Email text/message$
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt   $
EMAILMESSAGE="/tmp/emailmessage.txt"$
#/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE$
/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE$
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
:set list
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
that's not the actual header.

Do these things to find hidden characters:

vi the script, and type :set list
cat -v scriptname
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Ah my bad I spoke too soon, was writing 1 reply then saw your other but didn't pay enough attention to it.

Still would like to see the real headers if possible.
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
cat -v scriptname

?

And the command line?
0
 

Author Comment

by:xoxomos
Comment Utility
oracle@bb7b:~/scripts$ cat -v  email_results.sh
#!/bin/bash
# script to send simple email
# email subject
SUBJECT="EXPERIMENTAL SUBJECT"
# Email To ?
EMAIL="cornelius.taylor@csueastbay.edu"
# Email text/message
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt  
EMAILMESSAGE="/tmp/emailmessage.txt"
#/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE
/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE
oracle@bb7b:~/scripts$


./email_results.sh
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
>> i did put it on notepad and copied it to unix <<

I'd suggest rewriting the script from scratch under UNIX using vi!

I saw the weirdest things with copy and paste from Windows to Unix.

And with command line I meant what I posted above:

mail -s "MYSUBJECT" cornelius.taylor@csueastbay.edu < /etc/hosts
0
 

Author Comment

by:xoxomos
Comment Utility
We use gmail.  How do you see the real header?
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Open the mail, click the dropdown next to reply, and hit show original
0
 

Author Comment

by:xoxomos
Comment Utility
#!/bin/bash
SUBJECT="Experimental Subject"
EMAIL="cornelius.taylor@csueastbay.edu"
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
/bin/mail -s "${SUBJECT}" "${EMAIL}" < $EMAILMESSAGE


or
"email_result.sh" 6 lines, 239 characters
#!/bin/bash
SUBJECT="Experimental Subject"
EMAIL="cornelius.taylor@csueastbay.edu"
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
/bin/mail -s "SHOW SUBJECT" "${EMAIL}" < $EMAILMESSAGE
~
  Same thing either way :-(
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
So the script seems indeed OK.

Could you finally run the command line thing?

If this doesn't work either it must indeed have to do with Gmail.

Do you have an account with some other provider to check?

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
If this doesn't work either it must indeed have to do with Gmail.

Need headers!
0
 

Author Comment

by:xoxomos
Comment Utility
Yes, the same when sent to a different client

#!/bin/bash
SUBJECT="Experimental Subject"
EMAIL="zozimos@gmx.com"
awk '/deleted/' score_provider_delete.lst > /tmp/emailmessage.txt
EMAILMESSAGE="/tmp/emailmessage.txt"
/bin/mail -s "SHOW SUBJECT" "${EMAIL}" < $EMAILMESSAGE
~
~
~
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Last call for the command line test.


mail -s "MYSUBJECT" cornelius.taylor@csueastbay.edu < /etc/hosts
0
 

Author Comment

by:xoxomos
Comment Utility
Sorry
oracle@bb7b:~/scripts$
oracle@bb7b:~/scripts$ mail -s "MYSUBJECT" cornelius.taylor@csueastbay.edu < /etc/hosts
/export/home/oracle/dead.letter... Saved message in /export/home/oracle/dead.letter
oracle@bb7b:~/scripts$
0
 

Author Comment

by:xoxomos
Comment Utility

From oracle Mon Sep 12 12:20:03 2011
Return-Path: <oracle>
Received: (from oracle@localhost)
        by bb7b.csueastbay.edu (8.14.4+Sun/8.14.4/Submit) id p8CJK315011465;
        Mon, 12 Sep 2011 12:20:03 -0700 (PDT)
Date: Mon, 12 Sep 2011 12:20:03 -0700 (PDT)
From: oracle
Message-Id: <201109121920.p8CJK315011465@bb7b.csueastbay.edu>
MIME-Version: 1.0
Content-Type: text/plain

0 rows deleted.
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Show us the gmail headers.
0
 

Author Comment

by:xoxomos
Comment Utility



Like this??

Delivered-To: cornelius.taylor@csueastbay.edu
Received: by 10.231.103.74 with SMTP id j10cs13830ibo;
        Mon, 12 Sep 2011 15:11:24 -0700 (PDT)
Received: by 10.204.132.68 with SMTP id a4mr225358bkt.154.1315865483426;
        Mon, 12 Sep 2011 15:11:23 -0700 (PDT)
Return-Path: <noreply@experts-exchange.com>
Received: from slean2.csueastbay.edu (slean2.csueastbay.edu [134.154.192.27])
        by mx.google.com with ESMTP id i3si479914bke.79.2011.09.12.15.11.20;
        Mon, 12 Sep 2011 15:11:21 -0700 (PDT)
Received-SPF: pass (google.com: domain of noreply@experts-exchange.com designates 64.156.132.141 as permitted sender) client-ip=64.156.132.141;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of noreply@experts-exchange.com designates 64.156.132.141 as permitted sender) smtp.mail=noreply@experts-exchange.com
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AgcCAN2Cbk5AnISNi2dsb2JhbABCDoRHlE2OUBQBAQEKCwsbJoF8SEMCDRkCgQ2HYJdXjWCRfIEshDGBEQSHbYtOkGZY
X-IronPort-AV: E=Sophos;i="4.68,370,1312182000";
   d="scan'208";a="36181651"
Received: from www1.experts-exchange.com ([64.156.132.141])
  by slean2.csueastbay.edu with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Sep 2011 15:11:20 -0700
Received: from www1.experts-exchange.com (localhost [127.0.0.1])
      by www1.experts-exchange.com (8.14.4/8.14.4) with ESMTP id p8CMBJvE007704
      for <cornelius.taylor@csueastbay.edu>; Mon, 12 Sep 2011 15:11:19 -0700 (PDT)
      (envelope-from noreply@experts-exchange.com)
Date: Mon, 12 Sep 2011 15:11:19 -0700 (PDT)
From: Experts Exchange <noreply@experts-exchange.com>
To: cornelius.taylor@csueastbay.edu
Message-ID: <1399811084.654.1315865479833.JavaMail.ee@www1.experts-exchange.com>
Subject: Comment Added: Email Subject Not Showing
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Mailer: Experts Exchange
0
 

Author Comment

by:xoxomos
Comment Utility
Delivered-To: cornelius.taylor@csueastbay.edu
Received: by 10.231.103.74 with SMTP id j10cs14393ibo;
        Mon, 12 Sep 2011 15:50:38 -0700 (PDT)
Received: by 10.42.132.10 with SMTP id b10mr1024286ict.76.1315867838264;
        Mon, 12 Sep 2011 15:50:38 -0700 (PDT)
Return-Path: <oracle@bb7b.csueastbay.edu>
Received: from slean2.csueastbay.edu (slean2.csueastbay.edu [154.174.192.27])
        by mx.google.com with ESMTP id ve2si5695517icb.7.2011.09.12.15.50.36;
        Mon, 12 Sep 2011 15:50:36 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of oracle@bb7b.csueastbay.edu designates 154.174.192.26 as permitted sender) client-ip=154.174.192.26;
Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of oracle@bb7b.csueastbay.edu designates 154.174.192.26 as permitted sender) smtp.mail=oracle@bb7b.csueastbay.edu
X-IronPort-AV: E=Sophos;i="4.68,370,1312182000";
   d="scan'208";a="36183863"
Received: from bb7b.csueastbay.edu ([154.174.192.26])
  by iclean2.csueastbay.edu with ESMTP; 12 Sep 2011 15:50:36 -0700
Received: from bb7b.csueastbay.edu (localhost [127.0.0.1])
      by bb7b.csueastbay.edu (8.14.4+Sun/8.14.4) with ESMTP id p8CMoaPc016524;
      Mon, 12 Sep 2011 15:50:36 -0700 (PDT)
Received: (from oracle@localhost)
      by bb7b.csueastbay.edu (8.14.4+Sun/8.14.4/Submit) id p8CMoaXd016523;
      Mon, 12 Sep 2011 15:50:36 -0700 (PDT)
Date: Mon, 12 Sep 2011 15:50:36 -0700 (PDT)
From: oracle@bb7b.csueastbay.edu
Message-Id: <201109122250.p8CMoaXd016523@bb7b.csueastbay.edu>
MIME-Version: 1.0
Content-Type: text/plain
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Ah yes, finally.

OK so the Subject header is non-existent, but so is the body To, so that whole thing looks abnormal.

I have an idea...

which mail

Open in new window

then
ls -l `!!`

Open in new window

0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
btw, screw csueastbay, the real name is CSU Hayward ;)
0
 

Author Comment

by:xoxomos
Comment Utility
Watch it!!  ex President spent a LOT of money for that name change :-(
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Oh I'm just playin :p  I lived in Hayward a long time.
0
 

Author Comment

by:xoxomos
Comment Utility
racle@bb7b:/u05/datapump_directory$ which mail
/usr/bin/mail
oracle@bb7b:/u05/datapump_directory$


oracle@bb7b:/u05/datapump_directory$ ls -l `!!`
ls -l `which mail`
-r-x--s--x   1 root     mail       67932 Aug 10  2010 /usr/bin/mail
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Following Papertrip's idea:

What do you see with

alias mail

?
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Sorry, forgot that we're talking about a script here!
0
 

Author Comment

by:xoxomos
Comment Utility
racle@bb7b:~$ alias mail
-bash: alias: mail: not found
0
 

Author Comment

by:xoxomos
Comment Utility
OK. The administrator said i should actually be using sendmail where i would need to feed all that information myself.
Thanks
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Not sure why you gave the Accepted Solution to http:#36525987

wmp and I both spent a lot of time on this, both had great ideas, agreed on pretty much everything, but I still don't understand why you assigned points the way you did.

Is it possible to distribute the full amount of points split equally between wmp and I?  If you object wmp or have comments, please speak up.
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
I may be confused about how points work with questions since I haven't submitted one.  I got a base value of 250 for this, and I assume wmp got 500.  I don't want to take away any points from wmp, so is it possible for both of us to get 500?
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Don't worry, I got 250 just like you did!

Thx for the points, xoxomos!

wmp
0
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
Hah ok.

Wasn't trying to start any drama, just was a bit confused, only been on here for like a week :)

And yes thanks for the points! haha

Good luck.
0
 

Author Comment

by:xoxomos
Comment Utility
From what i see, 500 is the maximum possible on any question.  One of you noted there was nothing wrong with the script, you tested the script and concluded it work.  That is why i upped from 250 to 500, the maximum in order to give the original value to each.  No wmp got 250 also.  I know there used to be a way to work around the 500 point limit by putting out another question with a title like Points For Papertrip, but I think EE now discourages if not outright forbids that.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now