problems mime::lite

J

john.swilting

a small end of code
a small end of code contains die
but how to check that the email to pass in parameter is valid

sub SEND_MAIL{
my($attachement,$nom,$prenom,$mail,$body) = @_;

my $message_body .= $nom;
$message_body .= "\n";
$message_body .= $prenom;
$message_body .= "\n";
$message_body .= $body;

my $mime_msg = MIME::Lite->new(
From => $from_adress,
To => $mail,
Subject => 'contact',
Type => 'TEXT',
Data => $message_body,
) or die "error creating MIME body: $!\n";
if($attachement eq undef){
$mime_msg->send;
}else{
my $attachement_upload = '/var/www/html/upload/';
$attachement_upload .= $attachement;
$mime_msg->attach(
Type => 'image/gif',
Path => $attachement_upload,
Filename => 'attachement.gif'
) or die "error attaching image: $!\n";
$mime_msg->send;
}
}
 
T

Tad McClellan

john.swilting said:
if($attachement eq undef){


That probably does not do what you want.

If you want to test for undef, then:

if ( ! defined $attachement ) {

If you want to test for empty string then:

if ( $attachement eq '' )
or
if ( ! length $attachement )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top