sending email problem....
- From: tony.marquis@xxxxxxxxx (Tony Marquis)
- Date: Fri, 31 Mar 2006 09:56:51 -0500
Hi everyone,
The problem is really simple. When i try to send a message with this function with a wrong sender email address, my script just stops...
as an exemple : sender address tony.iagdyu@xxxxxxxxx the error message is - user not found on this server.... and the script stops.
-------------------------------------------------------------------------------------------------------------------------------------
use Mail::Sendmail;
use MIME::Lite;
use Email::Valid;
sub send_mail {
my ($mailto, $mailfrom, $sujet, $body_file, $file_send, $cc) = @_;
my $body_msg = "";
my $mail_err;
if ((Email::Valid->address( -address => $mailto, -mxcheck => 1 ) ? '1' : '0') eq '0' ) {
($mailto, $mailerr, $mailrom) = ($mailfrom, $mailto, "root\@feinc.com");
$sujet = "Destination invalide / Invalid destination $mailerr" . $sujet;
if ((Email::Valid->address( -address => $mailto, -mxcheck => 1 ) ? '1' : '0') eq '0' ) {
$sujet = "ERROR: $mailto $mailfrom " . $sujet;
$mailto = "tony\@feinc.com";
}
}
if ( $cc eq "1" ) {
### Create a new multipart message:
$msg = MIME::Lite->new(
From =>$mailfrom,
To =>$mailto,
Cc =>$mailfrom,
Subject =>$sujet,
Type =>'multipart/mixed'
);
}
else {
### Create a new multipart message:
$msg = MIME::Lite->new(
From =>$mailfrom,
To =>$mailto,
Subject =>$sujet,
Type =>'multipart/mixed'
);
}
open (FIC, $body_file) or die("Le fichier body $body n'existe pas\n");
while (<FIC>) {
$body_msg .= $_;
}
### Add parts (each "attach" has same arguments as "new"):
$msg->attach(Type =>'TEXT',
Data =>$body_msg
);
$msg->attach(Type =>'application/pdf',
Path =>$file_send,
Filename =>$file_name,
Disposition => 'attachment'
);
### Send in the "best" way (the default is to use "sendmail"):
MIME::Lite->send('smtp', "mail.xxxxxxxx.com", Timeout=>60);
$msg->send;
}
.
- Follow-Ups:
- Re: sending email problem....
- From: JupiterHost.Net
- Re: sending email problem....
- Prev by Date: Really simple XML question
- Next by Date: Re: Really simple XML question
- Previous by thread: Really simple XML question
- Next by thread: Re: sending email problem....
- Index(es):
Relevant Pages
|