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 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy SENDMAIL program config problem

    hi, i'm really new to all this web designing thing so i hope any of u guys here can help me a little bit. i have a website hosted at tripod and that website includes a form (please dont ask me how i maneged to build all that stuff) and after several days trying i still cant manage to make it work due to a problem with the SENDMAIL system.

    Tripod uses a perl script named TRIPODMAIL as SENDMAIL. Although my form processor is working properly (if i test the form by filling it out and hitting on the submit button i get a response from the form mailer) i still can't get this TripodMail thing to work.

    I know Tripod has a form processor script that would solve my problem but its just not what i really need since what i really want is to have the results of the form to be mailed to more than one person/email address.

    The form processor i'm using is Cliff's Form Mailer Version 1.0, i picked it instead of FormMail because i found it more easy to understand, after all i'm new to all these things.

    I'm attaching the TripodMail.pm script in case someone can help make it work along with my form processor.

    Thanks a lot for yout time.
    Gonzalo

    p.s. if you have any questions about my post please feel free to email me at gonzalo@ec-red.com or if you can suggest me a form handler site that lets me send the results of the form to more than one recipient i would appreciate it too.

    package TripodMail;

    ################
    # TripodMail.pm #
    #############################################################################
    # TripodMail is a module that allows you to send out email messages with
    # your scripts. In order to use it you'll have to have a mail template in
    # your cgi-bin directory. The mail template will need to look something
    # like this:

    # To: $email
    # From: FredFlintstone@hotmail.com
    # Subject: YabbaDabbaDoo!
    #
    # Hello $name,
    # Congratulations! You're user number $number of this mail script!

    # You can add other email headers (Reply-To:, Errors-To:, etc), but To:
    # and From: are manditory. You can customize your email by adding variables
    # wherever you would like to fill something in on the fly.
    # The sendMail method requires 2 parameters- the location of the mail
    # template file, and a reference to a hash of variables.
    # The keys of the varaible hash should correlate with the variables in the
    # mail template.

    # Example of use:
    # require TripodMail;
    # $MAIL = new TripodMail;
    # $mail_template = "./flintstones_mail.txt";
    # %variables = ('email' => 'Wilma@gurlmail.com',
    # 'name' => 'Wilma',
    # 'number' => '2');
    # $MAIL->sendMail($mail_template, \%variables);

    # Note: In order to prevent spamming, you will be limited to sending out 240
    # mails per day.
    ###########################################################################

    sub new {
    my $class = shift;
    my $self = {};
    bless $self, $class;
    return $self;
    }

    sub sendMail {
    # example: $MAIL->sendMail($template_file, \%hash_o_variables)
    # requires: 1) name of a file that is a template for the mail
    # 2) a reference to hash of variables to fill out the template
    # does: writes a mail file to member's directory to be mailed later
    # by sendmail
    # returns: 1 on success, 0 on failure

    my ($self, $template_file, $hash_ref) = @_;
    my ($message, $key, $time, $file);

    # error checking
    if ((! $template_file)||(! $hash_ref)){
    print STDERR "usage: sendMail(template_file, hash_reference)\n";
    return 0;
    }
    if (! -s $template_file){
    print STDERR "file does not exist or has a 0 size!\n";
    return 0;
    }

    # read in template
    open (MESSAGE, "<$template_file") or
    die "can't open template file $template for reading\n";

    undef $/;
    $message = <MESSAGE>;
    close (MESSAGE);
    $/ = "\n";

    # variable substitution
    foreach $key (keys (%{$hash_ref})){
    $message =~ s/\$$key/$hash_ref->{$key}/eg;
    }

    # check final template format
    if ($message !~ /to:.*\w+@\w+\.\w+/i){
    print STDERR "To: field missing or invalid recipient\n";
    return 0;
    }
    if ($message !~ /from:.*\w+@\w+\.\w+/i){
    print STDERR "From: field missing or invalid sender\n";
    return 0;
    }

    # write template to file
    $time = time();
    $file = 'mail.'.$time;

    open (FILE, ">$file") or
    die "can't open file: $file for writing\n";
    print FILE $message;
    close (FILE);

    return 1;
    }

    1;
    Last edited by gonzalo; 03-08-2003 at 05:23 PM.


 

Posting Permissions

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