problems mime::lite

Discussion in 'Perl Misc' started by john.swilting, Feb 12, 2007.

  1. 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;
    }
    }
    john.swilting, Feb 12, 2007
    #1
    1. Advertising

  2. john.swilting <> wrote:

    > 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 )


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 12, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John B. Kim

    MIME::Lite HTML message handling

    John B. Kim, Jan 18, 2004, in forum: Perl
    Replies:
    1
    Views:
    1,705
    Joe Smith
    Jan 19, 2004
  2. Zev Steinhardt

    Perl Mime::Lite question. Help please?

    Zev Steinhardt, Aug 24, 2004, in forum: Perl
    Replies:
    1
    Views:
    750
    dan baker
    Sep 1, 2004
  3. Aaron Brady

    SQL, lite lite lite

    Aaron Brady, Dec 29, 2008, in forum: Python
    Replies:
    15
    Views:
    749
    Aaron Brady
    Jan 1, 2009
  4. Jane Humbrey
    Replies:
    5
    Views:
    271
    Jane Humbrey
    Sep 1, 2003
  5. dan baker

    problems with MIME:Lite timeout

    dan baker, Aug 30, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    366
    dan baker
    Sep 2, 2004
Loading...

Share This Page