Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form mailer problem

    Hello,

    I could do with a bit of help on a CGI script I'm writing. Here is the script:

    Code:
    #!/usr/bin/perl
    
    use CGI; 
    
    my $query = new CGI;
    
    print $query->header ( );
    
    my $friends_name = $query->param("friends_name");
    my $friends_email = $query->param("friends_email");
    my $your_name = $query->param("your_name");
    
    open ( MAIL, "| /usr/lib/sendmail -t" );
    print MAIL "From: noreply\@simply-france.co.uk\n";
    print MAIL "To: $friends_email\n";
    print MAIL "Subject: La Maison des Tournesols (a suggestion from your friend $your_name)\n\n";
    print MAIL "Your friend $your_name has suggested that you may be interested in staying at La Maison des Tournesols, a bed & breakfast close to Niort in France.  For more details on this accommodation, please visit:  http://www.simply-france.co.uk/tournesols/\n\n";
    close ( MAIL );
    
    print <<END_HTML;
    <html>
    <head>
    <META HTTP-EQUIV="refresh" CONTENT="1;URL=http://www.simply-france.co.uk/tournesols/thanks.html">
    </head>
    <body>Processing...</body>
    </html>
    END_HTML

    It is being called from:
    http://www.simply-france.co.uk/tournesols/index2.html

    Basically, the line that is causing a problem is:
    Code:
    print MAIL "To: $friends_email\n";
    This is somehow stopping the script from working. If I replace the $friends_email variable with a hard-coded email address, for example:

    Code:
    print MAIL "To: gary\@domain.co.uk\n";
    ...the script works fine, and sends an email to that email address.

    What am I doing wrong?

    Thanks,
    Gary

  • #2
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Have you tried to add this after the freinds_email address has been declared?

    Code:
    $friends_email =~ s/@/\\@/;
    That makes the @ a \@

    hth

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #3
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    You need to validate all user supplied form data. Don't rely solely on javascript validation.

    The starting point to troubleshoot your problem would be to dump the vars (with Data::Dumper or one of its cousins) so you can see exactly what they hold. You also need to validate the submitted email address (with Email::Valid) to verify that it's a valid format.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •