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.
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 ...
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?