Script fails to send out email when HOSTNAME is included

Hi,

Below is my script which sends out emails.

more test.sh
  1 #!/bin/ksh
  2 {
  3         print "From: Prod@mycomp.com"
  4 #        print "From: Prod@`hostname`.com"
  5 #        print "From: Prod@${HOSTNAME}.com"
  6         print "To: me@mycomp.com"
  7         print "Subject: Usage Report"
  8         print "<html>"
  9         print "<body>"
 10         print "</body>"
 11         print "</html>"
 12 } | /usr/sbin/sendmail -t

The above script works fine and i am able to receive emails.

However, Instead of line 3 if i use line 4 or line 5 the script runs but i DO NOT RECEIVE any emails !!

Can you please suggest solutions for line 4 or line 5 which embeds the hostname in the From: section of the email to work ?

uname -a
SunOS mymac 5.11 11.3 sun4u sparc SUNW,SPARC-Enterprise

What do `hostname` and ${HOSTNAME} evaluate to on your server? I suspect that they may give you the fully qualified name, to which you are then appending .com

Try running the script with set -x inserted on line 2 and see if that illustrates the problem. You can also add the -v flag to sendmail for some feedback showing you what's going on.

Robin

Check the mail error log; mayhap the mails are rejected by a / the receiver as spam, e.g. based on the sender domain?

Can you tell me where can i find those mail logs for Solaris ?

---------- Post updated at 05:31 AM ---------- Previous update was at 05:23 AM ----------

I enabled set -x as well as verbose for the sendmail. Below is the differences between a successful email received (left hand) proceeds by the output from run with failed email.

1.

+ print 'From: Prod@mycomp.com'      vs         + print 'From: Prod@mymac.com'

2.

220 mymac.com ESMTP Sendmail 8.15.1+Sun/8.15.1; Thu, 27 Apr 2017 04:39:31 -0500 (CDT)    vs    220 mymac.com ESMTP Sendmail 8.15.1+Sun/8.15.1; Thu, 27 Apr 2017 04:41:12 -0500 (CDT)

3.
 >>> MAIL From:<user1@mymac.com> SIZE=94    vs     >>> MAIL From:<user1@mymac.com> SIZE=105

4. 
050 250-USD11CXB30CN02.biller.com Hello [10.6.140.57]     vs    050 250-USD11CXB30CN05.biller.com Hello [10.6.140.57]

5.
050 >>> MAIL From:<user1@mymac.com> SIZE=350     vs    050 >>> MAIL From:<user1@mymac.com> SIZE=361

6.
050 250 2.6.0 <201704270939.v3R9dVXc012460@mymac.com> [InternalId=59867549145530, Hostname=AUSYD11XB30CN02.biller.com] Queued mail for delivery
050 <Prod@mycomp.com>... Sent (<201704270939.v3R9dVXc012460@mymac.com> [InternalId=59867549145530, Hostname=AUSYD11XB30CN02.biller.com] Queued mail for delivery)
250 2.0.0 v3R9dVjp012461 Message accepted for delivery
Prod@mycomp.com... Sent (v3R9dVjp012461 Message accepted for delivery)


vs


050 250 2.6.0 <201704270941.v3R9fCOO014990@mymac.com> [InternalId=57724360464094, Hostname=AUMEL11XB30CN02.biller.com] Queued mail for delivery
050 <Prod@mycomp.com>... Sent (<201704270941.v3R9fCOO014990@mymac.com> [InternalId=57724360464094, Hostname=AUMEL11XB30CN02.biller.com] Queued mail for delivery)
250 2.0.0 v3R9fCHm014995 Message accepted for delivery
Prod@mycomp.com... Sent (v3R9fCHm014995 Message accepted for delivery)  

The only think i i can suspect is the difference at point 4.

Also, both the successful run and failed run say this >

Which makes me believe that the email may have been sent in both the cases but would have been blocked due to spam as @RudiC pointed.

I can paste the entire debug of a failed run if that helps ...

Can't tell for solaris, but chances are they're in /var/log/. You may refer to the syslog conf file.

I don't see a To: address anywhere. Perhaps it would be better to post (as two blocks) the output generated in a working case and a failing case. Perhaps with the full flow more obvious we can see what there is.

I'm assuming that you have a mail-relay defined for sendmail to pass this on to. What do the logs there say?

Robin