kasikiva has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl script which sends form mail and uses Sendmail - the form and script were done for a friend's web site - I desinged the site and wrote the script for him. When I transferred the files to my friend's web hosting service, the script worked fine, but didn't send any mail - I could see that it couldn't find 'sendmail' using the path I had defined. So, after four calls to interstar.net, I found out that they do not use sendmail - they use something called CDONTS - neither I nor another programmer I asked about it, had ever heard of it. The rep from Interstar sent me some code to add to my script, but it doesn't look right to me. Could you please give me some info about CDONTs (haven't been able to get the info from online searching - have found only references to CDONTs and ASP or VB script). Can I modify my existing Perl script to use them or not?? I need this info pretty quickly. I currently have the form on my friend's web site invoking the cgi script in my cgi-bin directory at work so that it will work for now. Thanks, guys, very much. BJ Perkins FCLA Gainesville, FL

Replies are listed 'Best First'.
Re: USING CDONT
by nimdokk (Vicar) on Oct 24, 2003 at 15:01 UTC
    You can access CDONTS with Win32::OLE, IIRC. I started to use it for automating emails on Windows, but ended up using Net::SMTP instead. Our requirements are pretty basic so that suffices.

    CDONTS can be used with VBScript:

    set ar = wscript.Arguments toaddr = ar.item(0) subject = ar.item(1) body = ar.item(2) Set objCDOMail = CreateObject("CDONTS.NewMail") objCDOMail.From = "mail@someplace.com" objCDOMail.to = toaddr objCDOMail.Subject = subject objCDOMail.Body = body objCDOMail.Send
    If you do a SuperSearch on cdonts here, you should be able to locate an example that describes using Win32::OLE.

    update: Here is the node that I was thinking of when I looked at this question: Mail with CDONTS.


    "Ex libris un peut de tout"
Re: USING CDONT
by bear0053 (Hermit) on Oct 24, 2003 at 14:06 UTC
    I never heard of CDONTS but here is a function that you can use to sendmail on just about any system
    use Mail::Sender; #this calls the function &send_email( from => $from, to => $to, subject => $subject, message => $message, ); #this is the function sub send_email{ my %data = @_; #Hash #Check required fields foreach(qw( to from subject message )){ if(!exists $data{$_}){ return(1, "Missing $_"); } } #Defaults $data{contenttype} = ($data{contenttype}) ? $data{contenttype} : ' +text/plain'; #Build CC string my ($CCs); if(ref($data{cc})){ $CCs = join(',', @{$data{cc}}); }elsif(length($data{cc}) > 0){ $CCs = $data{cc}; } #Build BCC string my ($BCCs); if(ref($data{bcc})){ $BCCs = join(',', @{$data{bcc}}); }elsif(length($data{bcc}) > 0){ $BCCs = $data{bcc}; } # Send the email my $mail_errors; my %mailInfo; $mailInfo{from} = $data{from}; $mailInfo{to} = $data{to}; $mailInfo{subject} = $data{subject}; $mailInfo{b_ctype} = $data{contenttype}; $mailInfo{ctype} = $data{contenttype}; $mailInfo{cc} = $CCs if($CCs); $mailInfo{bcc} = $BCCs if($BCCs); foreach my $smtp ('SMTP SERVER 1', 'SMTP SERVER N') { # Set up email information $mailInfo{'smtp'} = $smtp; $mailInfo{'msg'} = $data{message}; # Send the email if (ref((new Mail::Sender)->MailMsg(\%mailInfo))) { return (0, ''); # Success } # Problem with sending the email $mail_errors .= "SMTP address: $smtp\nError: " . $Mail::Sender::Error . "\n"; } if($mail_errors){ chop $mail_errors; return (1, $mail_errors); } }
    hope this helps
Re: USING CDONT
by matthewb (Curate) on Oct 24, 2003 at 14:17 UTC
    Um, I've seen CDONTS before. It is an ASP component.

    A google returns 42,000 hits right now. Do I lose XP for knowing that?

    MB

      For knowing it? Nah!

      For having the unmitigated gaul to admit to knowing it, here...in this bastion of antimsism...You Betcha :^)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      Hooray!

Re: USING CDONT
by diotalevi (Canon) on Oct 24, 2003 at 14:47 UTC
    Its worth noting that if you wrote your own formmail script you should probably check out the canonical example from nms. Moving to that would let you ensure your script isn't going to be used to send spam to others and that it isn't going to represent a security hole in your web sites.
Re: USING CDONT
by dragonchild (Archbishop) on Oct 24, 2003 at 14:17 UTC
    Googling with CDONTS perl, I found a number of useful pages. Try varying your search criteria.

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.