Checking whether the mail was sent or not


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking whether the mail was sent or not
# 1  
Old 07-24-2012
Checking whether the mail was sent or not

Hi all!!

Im using Ksh and working on Linux.

Im sending a mail to a mail_Id i have using the following code:
Code:
 
mutt -a file -s "some subject" $Mail_Id < Body.txt

I want to check whether the mail was actually sent or not. I tried the following code:
Code:
 
mutt -a file -s "some subject" $Mail_Id < Body.txt
if [ $? -eq 0 ]
then 
........
else
........
fi

The problem is even if the mail id i give is wrong, $? is 0
I dont know how to check whether it was actually sent or not.

Any help appreciated.

Thanks in advance !!

Last edited by Jayaraman; 07-24-2012 at 11:33 AM.. Reason: clarification
# 2  
Old 07-24-2012
Hi,

You could check in /var/spool/mail/$username, as far as mutt goes - mutt is a lightweight mail client suitable for sending and reading mail.

However mutt does create temp files that will be deleted on a successfule send - these reside in /tmp and are usuall named "muttXXXXX" - you could test if it is still there which would indicate that it has not been sent.

Regards

Dave
# 3  
Old 07-24-2012
@gull04

what do you mean by $username in /var/spool/mail/$username?
Im asking this because i dont use it in my code.
# 4  
Old 07-24-2012
What do you mean by 'actually sent'?

If your emailer returns success and your mailserver isn't broken, it was probably sent.

Whether it actually reached its destination is another question. The only way to tell that is bounce messages, and if you get them at all they may take hours to days to arrive.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Shell Programming and Scripting

A shell script for checking the last image and sending it in attachment to mail

Hello every one. I use mutt : "mpack -s "Test" /home/pi/Pictures/2018-10-05_23_10_40.jpg my_email_addres " to send me a particular picture with the name of the data+jpg in a pictures folder, but this folder I use it for a timelapse proyect with more pictures , and what I need is... (2 Replies)
Discussion started by: maxbcn
2 Replies

3. Shell Programming and Scripting

Script for checking files for last hour and send a mail

Hello, I need to write a script to check the files in one folder , if that folder doesn't have files generated from last 1 hr then we need to send mail to particular persons. So Can you please help me to write script to check the files and send email. Thank you.. (1 Reply)
Discussion started by: archana23
1 Replies

4. SCO

Stop boot system at "Checking protected password and checking subsystem databases"

Hi, (i'm sorry for my english) I'm a problem on boot sco unix 5.0.5 open server. this stop at "Checking protected password and checking subsystem databases" (See this image ) I'm try this: 1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094 2) SCO: SCO Unix - Server hangs... (9 Replies)
Discussion started by: buji
9 Replies

5. Shell Programming and Scripting

Checking postfix mail log with AWK

Hello, Few days ago I found a person checking his mail log by AWK. But unfortunately I forget to take the command from him. Today I got to need that command badly. Here is a reference. When I check from my mail log like this it will not show me the details. grep "from=<noreply@panix.com>"... (2 Replies)
Discussion started by: rinti
2 Replies

6. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

7. Shell Programming and Scripting

Checking the status of mail sent.

Hi, Is there any way to check the status of the mail sent or not.e.g mail -s "Error Message" abc@xyz.com <aaa/bbb/data.txt Can it return a status code which will confirm the delivery of mail sent?Please suggest. Thanks, Anil (1 Reply)
Discussion started by: anil029
1 Replies

8. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

9. UNIX for Dummies Questions & Answers

Sending mail, status checking

After I send a mail thr unix with following command uuencode tmpFile | mailx -s "sub1" emailid Yet, I havent received this mail at intended mail client. In order to find out if the sent mail action resulted in failure, I checked at /usr/spool/mail/userid But there also I couldnt find... (1 Reply)
Discussion started by: videsh77
1 Replies

10. UNIX for Dummies Questions & Answers

mail problem (NOT Mail or Mail.app)

When I try to use the CLI mail, I get the following error. What's wrong? Welcome to Darwin! % mail root Subject: test test . EOT % /etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory Do I just need to change the... (1 Reply)
Discussion started by: chenly
1 Replies
Login or Register to Ask a Question