Sponsored Content
Full Discussion: SendMail Function Failure
Top Forums Shell Programming and Scripting SendMail Function Failure Post 302467226 by vigdmab on Thursday 28th of October 2010 04:06:45 PM
Old 10-28-2010
SendMail Function Failure

Hi All,

Background: We use SendMail function (given below) to send emails to users. The email address are obtained as ouptut of a stored procedure in sybase.

We have defined a SendMail function as below in a .pm file and it is used in a .pl script.

Code Snippet:
Code:
sub SendMail
{
    my (
         $Message ,
         $Subject ,
         $To,
         $CC
       ) = @_;
    my ($sec, $min, $hour, $mday, $mon, $year) = localtime(time) ;
    my $PgmName = "$hour:$min:$sec" ;
    Log( "\nRecepients To: << $To >>\n" ) ;
    Log( "\nRecepients CC: << $CC >>\n" ) ;
    open(SENDMAIL, "|/usr/lib/sendmail -oi -t")
        || die "Can't fork for sendmail: $!\n";
#Content-Transfer-Encoding: quoted-printable
    print SENDMAIL << "EOF";
From: $MAIL_FROM
Date: $PgmName
To: $To
CC: $CC
Subject: $Subject
Content-Type: text/html; charset="iso-8859-1"
$Message
EOF
close(SENDMAIL) || die "sendmail didn't close nicely";
   if( $? !=0  )
   {
      Log("System Mail Failed");
   }
   else
   {
      Log ("Mail Sent Successfully");
   }
}

The above SendMail is called in a perl script.

Issue:

Lets say we have 10 email address to which emails has to be send, and the 5th email address's mail box is no longer available though the email address is a valid one. Henceforth the sendmail function fails with "
sendmail didn't close nicely " message and email is not send to the rest of the people.

Expected Resolution Options

i) Validate whether the mailbox is still active. OR
ii) Prevent the sendmail from failing & continue to send the mail to the other people.

Kindly provide a possible solution. Thanking All in advance for your time.

Last edited by zaxxon; 10-29-2010 at 02:22 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Capturing sendmail success/failure?

I am working on a project that will use sendmail to send reports form a shell script. Since these reports are very important and go out at all times of the day, I need to be able to capture if sendmail is unsuccessful or errors out. The emails may have multiple recipients with multiple attachments.... (2 Replies)
Discussion started by: ssracer
2 Replies

2. Shell Programming and Scripting

sendmail function

Hi all, Following is the code for sending mail with attachment #! /bin/ksh SUBJ="Send mail from Unix PHDCAP12 " TO=tmp@rediff.com CC=tmp1@rediff.com ( cat << ! To : ${TO} Subject : ${SUBJ} Cc : ${CC} ! cat << ! HOPE THIS WORKS Test123 This sample E-mail message with the Unix... (1 Reply)
Discussion started by: radhika03
1 Replies

3. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

4. UNIX for Dummies Questions & Answers

boot up failure unix sco after power failure

hi power went out. next day unix sco wont boot up error code 303. any help appreciated as we are clueless. (11 Replies)
Discussion started by: fredthayer
11 Replies

5. Shell Programming and Scripting

Error Message in function causing failure.....

I have a long busybox ash script that has 3 stages. 1. Identify and Capture information on variable data sources, output the information to text file on each data source. 2. Using data from 1 above now actually do data processing on each individual dataset. 3. Produce report. So... (6 Replies)
Discussion started by: tesser
6 Replies

6. UNIX for Advanced & Expert Users

Sendmail questions, SCO 5.0.6 sendmail 8.11.0

I am running SCO 5.0.6 and using sendmail 8.11.0 and having issues with smtp authentication. When trying to send mail the following message will kick back. (reason: 530 5.7.1 Authentication required) 530 5.7.1 Authentication required Not sure what needs to be tweeked in sendmail.cf but I... (1 Reply)
Discussion started by: ziggy6
1 Replies

7. Shell Programming and Scripting

Sendmail function

Hi , The default mail/mailx function is not supporting HTML/ Headers. But sendmail does. Can anyone of you please guide me in creating function like 1. Sending HTML Emails. FN_SEND_EMAIL "$MAIL_BODY" "HTML" $MAIL_BODY="<html><table><tr><td>Just</td><td>testing</td></tr></table>" ... (1 Reply)
Discussion started by: Anupam_Halder
1 Replies

8. Solaris

Clarifying sendmail configuration - sendmail-client offline

Hi all, I have read about sendmail running as 2 separate process. 1 as a MSP, and the other as the real daemon or MTA. In my current configuration, the sendmail-client is disabled. Both submit.cf and sendmail.cf are left as default untouch I do not specified any mailhost... (3 Replies)
Discussion started by: javanoob
3 Replies

9. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies

10. UNIX for Beginners Questions & Answers

Problems host name lookup failure sendmail

Hi I have a problem in sendmail Freebsd when sending emails to yahoo as an example, I get: Sep 5 10:05:43 local50 sm-mta: STARTTLS=client, error: connect failed=-1, SSL_error=1, errno=0, retry=-1 Sep 5 10:05:43 local50 sm-mta: STARTTLS=client: 43926:error:1407742E:SSL... (3 Replies)
Discussion started by: rickyarge92
3 Replies
MH-TAILOR(5)							     [nmh-1.5]							      MH-TAILOR(5)

NAME
mh-tailor, mts.conf - mail transport customization for nmh message handler SYNOPSIS
/etc/nmh/mts.conf DESCRIPTION
The file /etc/nmh/mts.conf defines run-time options for those nmh programs which interact (in some form) with the message transport system. At present, these (user) programs are: ap, conflict, inc, msgchk, msh, post, rcvdist, and rcvpack. Each option should be given on a single line. Blank lines and lines which begin with `#' are ignored. The options available along with default values and a description of their meanings are listed below: mts: The mail transport method to use. The two acceptable options are smtp (which is the default), and sendmail. If you use smtp, this will enable a direct SMTP (simple mail transport protocol) interface in nmh. When sending mail, instead of passing the message to the mail transport agent, post will open a socket connection to the mail port on the machine specified in the servers entry. If you use sendmail, then post will send messages by forking a local copy of sendmail. Currently it will still speak SMTP with this local copy of sendmail. localname: The hostname nmh considers local. It should typically be a fully qualified hostname. If this is not set, depending on the version of UNIX you're running, nmh will query the system for this value (e.g. uname, gethostname, etc.), and attempt to fully qualify this value. If you are using POP to retrieve new messages, you may want to set this value to the name of the POP server, so that outgoing message appear to have originated on the POP server. localdomain: If this is set, a `.' followed by this string will be appended to your hostname. This should only be needed, if for some reason nmh is not able to fully qualify the hostname returned by the system (e.g. uname, geth- ostname, etc.). clientname: This option specifies the host name that nmh will give in the SMTP HELO (and EHLO) command, when posting mail. If not set, the default is to use the host name that nmh considers local (see localname above). If this option is set, but empty, no HELO command will be given. Although the HELO command is required by RFC-821, many SMTP servers do not require it. Early versions of SendMail will fail if the hostname given in the HELO command is the local host. Later versions of SendMail will complain if you omit the HELO command. If you run SendMail, find out what your system expects and set this field if needed. systemname: This option is only used for UUCP mail. It specifies the name of the local host in the UUCP "domain". If not set, depending on the version of UNIX you're running, nmh will query the system for this value. This has no equivalent in the nmh configuration file. mmdfldir: /var/mail The directory where maildrops are kept. If this option is set, but empty, the user's home directory is used. This overrides the default value chosen at the time of compilation. mmdflfil: The name of the maildrop file in the directory where maildrops are kept. If this is empty, the user's login name is used. This over- rides the default value (which is empty). mmdelim1: 01010101 The beginning-of-message delimiter for maildrops. mmdelim2: 01010101 The end-of-message delimiter for maildrops. maildelivery: /usr/lib/mh/maildelivery The name of the system-wide default maildelivery file. See slocal(1) for the details. everyone: 200 The highest user-id which should NOT receive mail addressed to "everyone". noshell: If set, then each user-id greater than "everyone" that has a login shell equivalent to the given value (e.g., "/bin/csh") indicates that mail for "everyone" should not be sent to them. This is useful for handling admin, dummy, and guest logins. SMTP support This option is only available if you set mts to smtp. servers: localhost A lists of hosts and networks which to look for SMTP servers when posting local mail. It turns out this is a major win for hosts which don't run an message transport system. The value of servers should be one or more items. Each item is the name of a host which is (hopefully) running a SMTP server. SendMail This option is only available if you set mts to sendmail. sendmail: /usr/sbin/sendmail The pathname to the sendmail program. Post Office Protocol This option is only available if you have compiled nmh with POP support enabled (i.e., "--enable-pop"). pophost: The name of the default POP service host. If this is not set, then nmh looks in the standard maildrop areas for waiting mail, other- wise the named POP service host is consulted. File Locking A few words on locking: nmh has several methods for creating locks on files. When configuring nmh, you will need to decide on the locking style and locking directory (if any). The first controls the method of locking, the second says where lock files should be created. To configure nmh for kernel locking, use the "--with-locking=flock" configure option if you want to use the flock system call; use "--with- locking=lockf" if you want to use the lockf system call; or use "--with-locking=fcntl" if you want to use the fcntl system call for kernel- level locking. Instead of kernel locking, you can configure nmh to use dot locking by using "--with-locking=dot". Dot locking specifies that a file should be created whose existence means "locked" and whose non-existence means "unlocked". The name of this file is constructed by append- ing ".lock" to the name of the file being locked. If "--enable-lockdir=directory" is not specified at build time, lock files will be cre- ated in the directory where the file being locked resides. Otherwise, lock files will be created in the directory specified by "--enable- lockdir". Prior to installing nmh, you should see how locking is done at your site, and set the appropriate values. FILES
/etc/nmh/mts.conf nmh mts configuration file PROFILE COMPONENTS
None SEE ALSO
mh-mts(8), post(8) DEFAULTS
As listed above MH.6.8 11 June 2012 MH-TAILOR(5)
All times are GMT -4. The time now is 05:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy