Unable to recieve email using sendmail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to recieve email using sendmail
# 1  
Old 04-25-2017
Hammer & Screwdriver Unable to recieve email using sendmail

Hi, Here is my script to send out emails.
Code:
#!/bin/ksh

{
        print "From: Prod@`hostname`.mycomp.com"
        print "To: me@mycomp.com"
        print "MIME-Version: 1.0"
        print "Content-Type: text/html"
        print "Subject: Usage Report"
        print ""
        print "<html>"
        print "<body>"
        print "<p>Today Usage Report for Server</p>"

        print "</body>"
        print "</html>" } | /usr/sbin/sendmail -t

This script runs but i do not receive any email to my email address me@mycomp.com.

Code:
uname -a SunOS myhost 5.11 11.3 sun4u sparc SUNW,SPARC-Enterprise

Can you please suggest how can i debug and fix the problem ?

---------- Post updated 04-25-17 at 02:47 AM ---------- Previous update was 04-24-17 at 05:07 PM ----------

Here is all of my troubleshooting.

Code:
ps -ef|grep -i sendmail|grep -v grep
   smmsp  6755  4646   0   Apr 20 ?           0:01 /usr/lib/inet/sendmail -Ac -q15m
    root  6757  4646   0   Apr 20 ?           0:11 /usr/lib/inet/sendmail -bl -q15m

mailx does not work as you can see below.

Code:
 mailx -s "test messages from unixrock" me@mycomp.com


^C     <---- Pressed Ctrl+C to terminate as i did not get any output after a while
(Interrupt -- one more to kill letter)
^C"/export/home/user1/dead.letter" 4/4

/var/adm/messages is empty ... there is no logging there.
Code:
ls -ltr /var/adm/messages
-rw-r--r--   1 root     root           0 Apr 14 03:10 /var/adm/messages

Checking mail relay server in /etc/mail/submit.cf
Code:
grep DS /etc/mail/submit.cf
DS
# Return-Receipt-To: header implies DSN request
# DHParameters (only required if DSA/DH is used)

Checking whether mail port (port 25) is listening. It indeed is.
Code:
telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mymac ESMTP Sendmail 8.15.1+Sun/8.15.1; Tue, 25 Apr 2017 03:00:26 -0500 (CDT)

The strange thing is that this server does send out emails which are set in crontab and does not when i m trying to manually run the crontab scripts.

Its more like intermittent behavior.

Important Note: A strange observation: while mailx command shown above does not work BUT the below mailx command works fine and WE do receive emails.

Code:
mailx -s "test messages from unixrock" me@mycomp.com < /etc/hosts

Can you please guide me to get this to work or debug the root cause ?

All of the above makes me believe there is something not write with our test.sh our code in the OP.

I further trimmed down my test.sh script as you see below.

Code:
#!/bin/ksh  
{         
print "From: Prod@`hostname`.mycomp.com"         
print "To: me@mycomp.com"         
print "Subject: Usage Report"         
print "<html>"         
print "<body>"         
print "</body>"         
print "</html>" 
} | /usr/sbin/sendmail -t

But it still does not work Smilie

If someone can point that out ... it will be great.

Please suggest.

Last edited by mohtashims; 04-25-2017 at 05:21 AM..
# 2  
Old 04-25-2017
The command:
Code:
mailx -s "test messages from unixrock" me@mycomp.com < /etc/hosts

works while the command:
Code:
mailx -s "test messages from unixrock" me@mycomp.com

hangs because the mailx command reads the text to be sent as the body of your message from standard input. When you type the second command above it is sitting there waiting for you to type in the text to be sent.

If you type in the text that you want to be the body of your message after entering the 2nd command above and then hit Ctl-D to terminate the message, the command should do what you seem to expect.
# 3  
Old 04-25-2017
Bug

Quote:
Originally Posted by Don Cragun
The command:
Code:
mailx -s "test messages from unixrock" me@mycomp.com < /etc/hosts

works while the command:
Code:
mailx -s "test messages from unixrock" me@mycomp.com

hangs because the mailx command reads the text to be sent as the body of your message from standard input. When you type the second command above it is sitting there waiting for you to type in the text to be sent.

If you type in the text that you want to be the body of your message after entering the 2nd command above and then hit Ctl-D to terminate the message, the command should do what you seem to expect.
True.. while i understand that > the main problem is with the OP test.sh script.

---------- Post updated at 09:40 AM ---------- Previous update was at 05:22 AM ----------

I got the line causing the email to fail and not showup in my inbox.

I changed this line test.sh From
Code:
        print "From: Prod@`hostname`.mycomp.com"

to
Code:
        print "From: me@mycomp.com"

and now it works.

Can you tell me why is this line print "From: Prod@`hostname`.mycomp.com" FAILS to send out emails and what is the FIX ??

Last edited by mohtashims; 04-25-2017 at 06:00 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need help with sendmail email filtering on FreeBSD

Hi All, Sorry, for the double posting. Don't know how to move to a different forum. I am very new to Unix. I have a test server running FreeBSD 10.1 and SendMail 8.14.9. I need to filter incoming emails based on the sender's email address or domain and forward them to another address on a... (1 Reply)
Discussion started by: simplemind
1 Replies

2. Linux

Unable to send email with sendmail from PHP 5.3 on CentOS VM

I have a longstanding issue on my CentOS 5.6 VM where I am unable to send email from my PHP application. This is the last bunch of lines from my /var/log/maillog file. Feb 14 10:29:16 dev53 sendmail: s1EATEEo004637: Authentication-Warning: www.craig.dev-crmpicco.lan: apache set sender to... (2 Replies)
Discussion started by: crmpicco
2 Replies

3. AIX

Set email Priority using sendmail

Hi everyone, I'm trying to send an email on unix using sendmail command. For setting the priority to high I use: X-Priority: 1 And it works on HP but when I tried it on AIX the email is sent but no priority!! Anyone can help me Thanks in advance, Hiposh (3 Replies)
Discussion started by: hiposh
3 Replies

4. Debian

sendmail taking too much time to send a email

Hi , I'm using sendmail command to send a email. To send a email sendmail taking 3minutes to complete the process. Is there any configuration needs to be done in server or another solution is there to resolve this issue. Thanks in Advance. Regards Latika (1 Reply)
Discussion started by: latika
1 Replies

5. Shell Programming and Scripting

Unable to populate subject field of the email while using sendmail

Hi, Can anyone kindly provide some information about how to populate the subject field of the email while using the sendmail utility ? Itried the following command line argument : echo -e "Body of the email" | /usr/lib/sendmail -f from@from.com -t to@to.com -s " Subject of the email" ... (4 Replies)
Discussion started by: sdiptanil
4 Replies

6. Solaris

Outbound email re-direct using Sendmail

I need to reconfigure Sendmail to strip the SMTP email addresses from all email and replace them with a single address used for testing purposes. I have a vended application hosted on Solaris 10 servers. I have access to support the application framework (IBM WebShere Application Server 6.1),... (1 Reply)
Discussion started by: dunkar70
1 Replies

7. UNIX and Linux Applications

Sendmail outgoing email rate

Does anyone know what's Sendmail outgoing email rate? e.g. 1000 outgoing email per minutes. If so, can we modify it? Thanks. :) (1 Reply)
Discussion started by: sunmagic2003
1 Replies

8. HP-UX

Sendmail not submitting Email on '.'

I have several HP/UX nodes running Sendmail 8.13 ...some work fine, some don't. When an Email is coming in, the 'DATA' command never ends. The other side of the connection gets to the point where it enters the '.' on a line by itself, but sendmail doesn't accept it...if fact it keeps on holding... (8 Replies)
Discussion started by: john_exonets
8 Replies

9. Red Hat

Unable to install & configure Sendmail

Hi All • Regarding installing sendmail pkg in server, I tried to install the pkg but getting the below errors as shown below - any idea on this? • But I have successfully installed sendmail-cf pkg in the server box • But that is not sufficient we also need to install sendmail pkg • Help is... (2 Replies)
Discussion started by: csaha
2 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question