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
POSIX::strptime(3pm)					User Contributed Perl Documentation				      POSIX::strptime(3pm)

NAME
POSIX::strptime - Perl extension to the POSIX date parsing strptime(3) function SYNOPSIS
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = POSIX::strptime("string", "Format"); DESCRIPTION
Perl interface to strptime(3) FUNCTIONS
strptime ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = POSIX::strptime(string, format); The result for any value not extracted is not defined. Some platforms may reliably return "undef", but this is dependent on the strptime(3) function in the underlying C library. For example, only the following fields may be relied upon: my ($min, $hour) = ( POSIX::strptime( "01:23", '%H:%M' ) )[1,2]; my ($mday, $mon, $year) = ( POSIX::strptime( "2010/07/16", '%Y/%m/%d' ) )[3,4,5]; Furthermore, not all platforms will set the $wday and $yday elements. If these values are required, use "mktime" and "gmtime": use POSIX qw( mktime ); use POSIX::strptime qw( strptime ); my ($mday, $mon, $year) = ( POSIX::strptime( "2010/07/16", '%Y/%m/%d' ) )[3,4,5]; my $wday = ( gmtime mktime 0, 0, 0, $mday, $mon, $year )[6]; SEE ALSO
strptime(3) AUTHOR
Philippe M. Chiasson <gozer@cpan.org> Kim Scheibel <kim@scheibel.co.uk> REPOSITORY
http://svn.ectoplasm.org/projects/perl/POSIX-strptime/trunk/ COPYRIGHT
Copyright 2005 by Philippe M. Chiasson <gozer@cpan.org>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2010-07-16 POSIX::strptime(3pm)
All times are GMT -4. The time now is 05:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy