sending email problem....



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;
}


.



Relevant Pages

  • Re: Secure Form Script?
    ... Why not just a form that accepts a subject, a sender email ... Even if manage to hijack the fields due to improperly vetted ... >>such a script to change the destination address and point it at a list ... > It's usually not sufficient to store the to addresses on the server ...
    (Focus-Linux)
  • Re: sending email problem....
    ... Tony Marquis wrote: ... When i try to send a message with this function with a wrong sender email address, my script just stops... ... I say that because its just a sub, there is no call to it with example data or the actual error (which would be helpfull to see where its coming from, especially if you are reporting the error ...
    (perl.beginners)
  • Re: Scripts required
    ... I'm looking for a script to extract all sender email addresses from a ... customers mailbox and dump them into a text file. ...
    (microsoft.public.exchange.admin)
  • Scripting Advice
    ... I'm looking for a script that will automatically file all read messages in ... my personal folder by sender email address, creating a new folder if one ... Is such a script available? ...
    (microsoft.public.outlook.general)
  • Re: Sending a binary file (and other stuffs) with fsockopen
    ... Janwillem Borleffs wrote: ... > do is to call the script with some parameters and get the response. ... You can only use POST to send binary data ... are part of a multipart message ...
    (comp.lang.php)