?
Solved

Email Subject Not Showing

Posted on 2011-09-12
44
Medium Priority
?
562 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 17
  • 16
  • 11
44 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36525857
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
ID: 36525928
#!/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 1000 total points
ID: 36525987
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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36526008
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 1000 total points
ID: 36526042
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
ID: 36526059
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
ID: 36526085
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
ID: 36526091
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
ID: 36526102
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
ID: 36526110
Syntactically - yes!

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

0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36526113
Yep I'm on board with your latest guess :)
0
 

Author Comment

by:xoxomos
ID: 36526138
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
ID: 36526154
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
ID: 36526163
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
ID: 36526172
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
ID: 36526174
cat -v scriptname

?

And the command line?
0
 

Author Comment

by:xoxomos
ID: 36526242
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
ID: 36526258
>> 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
ID: 36526268
We use gmail.  How do you see the real header?
0
 
LVL 21

Expert Comment

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

Author Comment

by:xoxomos
ID: 36526332
#!/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
ID: 36526345
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
 
LVL 21

Expert Comment

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

Need headers!
0
 

Author Comment

by:xoxomos
ID: 36526392
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
ID: 36526408
Last call for the command line test.


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

Author Comment

by:xoxomos
ID: 36526418
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
ID: 36526421

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
ID: 36526442
Show us the gmail headers.
0
 

Author Comment

by:xoxomos
ID: 36526547



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
ID: 36526558
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
ID: 36526574
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
ID: 36526579
btw, screw csueastbay, the real name is CSU Hayward ;)
0
 

Author Comment

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

Expert Comment

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

Author Comment

by:xoxomos
ID: 36531053
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
ID: 36531665
Following Papertrip's idea:

What do you see with

alias mail

?
0
 
LVL 68

Expert Comment

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

Author Comment

by:xoxomos
ID: 36531714
racle@bb7b:~$ alias mail
-bash: alias: mail: not found
0
 

Author Comment

by:xoxomos
ID: 36532674
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
ID: 36532727
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
ID: 36532739
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
ID: 36532776
Don't worry, I got 250 just like you did!

Thx for the points, xoxomos!

wmp
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36532788
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
ID: 36532812
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

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

770 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