catalyst2 community forums  

Go Back   catalyst2 community forums > Support > E-Mail Support

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 07-11-2007, 10:09 AM   #1 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
Email in perl script using CDONTS

Please forgive what may be a dumb question from a newbie - however, here goes!

I've managed to send email from an .asp script for a simple "contact us" forms script; the successful code is:

<%
Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = "mail@myisp.co.uk"
ObjMail.From = "mail@mycatalystdomain.org.uk"
ObjMail.Subject = "New Email from Website"
ObjMail.Body = "New Email from Website"
ObjMail.Send
Set ObjMail = Nothing
%>

However, I am failing when I try to do a similar thing with a perl script; I've tried many variations of the following. The rest of the perl script (a guest book) is functioning absolutely fine, so I guess I've got the perl environment set up ok. I just want it to email me when somebody makes a new entry; the script is actually getting to this part of the code:

use Win32::OLE;
my $perlmessage = Win32::OLE->new('CDONTS.NewMail');
$perlmessage->{From} = "mail@mycatalystdomain.org.uk";
$perlmessage->{To} = "mail@myisp.co.uk";
$perlmessage->{Subject} = "New Guestbook Entry from Website";
$perlmessage->{Body} = "New Guestbook Entry from Website";
$perlmessage->Send();
$perlmessage = undef;

Should the email addresses be in single quotes, with the @ escaped? Or should it be from mail.mycatalystdomain.org.uk? Help??!! TIA...

Bilsdale
Bilsdale is offline   Reply With Quote
Old 07-11-2007, 10:33 AM   #2 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Hum, good question

Does the script give any error?
paulredpath is offline   Reply With Quote
Old 07-11-2007, 10:55 AM   #3 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
No error messages...

Hi Paul - no, no error messages. Just goes sailing clean through.

If I corrupt the code immediately around that area, I get:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
which is why I believe it's passing through that subroutine.

Any diagnostics, or "print variables / status" lines I can put in around that area, that might shed some light?

Cheers!
Bilsdale is offline   Reply With Quote
Old 07-11-2007, 04:09 PM   #4 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Unfortunately I am not a perl coder :/

However, just wondering if we have the win32:le module installed, can you email me your domain and I will check on that server for you.
paulredpath is offline   Reply With Quote
Old 09-11-2007, 09:52 AM   #5 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
Email in perl script using CDONTS - is win32:OLE module installed?

Paul - My domain is ******************.org.uk Is the win32le module installed??

Your help is appreciated :-)

Last edited by Bilsdale; 09-11-2007 at 03:13 PM.
Bilsdale is offline   Reply With Quote
Old 09-11-2007, 10:28 AM   #6 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Could you try that now please?
paulredpath is offline   Reply With Quote
Old 09-11-2007, 01:10 PM   #7 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
Still no joy, Paul ;-(

Tried all manner of email addresses - in double quotes, single quotes, single quotes with the @ escaped, or from mail.mycatalystdomain.org.uk etc. Can one of your perl experts please cast an eye over what I'm trying to do and advise?

Alternatively, the following .asp script as follows sends me an email in seconds... Is it therefore possible to call an existing .asp script from a perl script, or am I talking c**p?

<%
Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = "mail@myisp.co.uk"
ObjMail.From = "mail@mycatalystdomain.org.uk"
ObjMail.Subject = "New Email from Website"
ObjMail.Body = "New Email from Website"
ObjMail.Send
Set ObjMail = Nothing
%>
Bilsdale is offline   Reply With Quote
Old 09-11-2007, 02:08 PM   #8 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Darn :/

Can you pm me the path to the script so I can test it and do some debugging?
paulredpath is offline   Reply With Quote
Old 09-11-2007, 02:51 PM   #9 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
\****.pl

hth...
Bilsdale is offline   Reply With Quote
Old 09-11-2007, 02:54 PM   #10 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Hi,

Where in that do I send an email to get the error?
paulredpath is offline   Reply With Quote
Old 09-11-2007, 03:12 PM   #11 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks for removing the path to the script - I was unhappy about leaving that in clear...

Not sure I understand your question; if you find "sub send_mail" you'll be in the send mail subroutine. Clearly the original script was written for UNIX -

$mailprog = "/usr/sbin/sendmail"; # path to sendmail

is still there. So I have inserted a Windows equivalent invoking CDONTS, and hashing out the UNIX stuff. But everything else works fine for the Windows server - the guestbook application works fine.

Any bright ideas?
Bilsdale is offline   Reply With Quote
Old 12-11-2007, 11:22 AM   #12 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Hi,

Sorry what I am trying to check are the steps I need to invoke that method, just posting on the guestbook doesnt seem to?
paulredpath is offline   Reply With Quote
Old 12-11-2007, 05:44 PM   #13 (permalink)
Registered User
 
Join Date: Oct 2007
Posts: 7
Hi Paul

Posting on http://www.*********html should not only add an entry, but also call the subroutine that emails me. The entry to address book works fine, and the perl script is clearly getting to the subroutine (since if I corrupt a line there, the whole script fails with:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. )
In passing through the subroutine, the mailing fails, with nothing being received - and with no error message.

I guess the question is "is there anything wrong with the perl subroutine":
use Win32::OLE;
my $perlmessage = Win32::OLE->new('CDONTS.NewMail');
$perlmessage->{From} = "mail@mycatalystdomain.org.uk";
$perlmessage->{To} = "mail@myisp.co.uk";
$perlmessage->{Subject} = "New Guestbook Entry from Website";
$perlmessage->{Body} = "New Guestbook Entry from Website";
$perlmessage->Send();
$perlmessage = undef;
Thanks in anticipation of your ongoing help :-)

Last edited by Bilsdale; 10-12-2007 at 01:39 PM.
Bilsdale is offline   Reply With Quote
Old 13-11-2007, 02:12 PM   #14 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Hi,

Found this handy snippet which appears to work

use Win32::OLE;
$cd = Win32::OLE->new("CDONTS.NewMail") || die $!;
$cd->{From}="test\@catalyst2.com";
$cd->{To}="test\@gmail.com";
$cd->{Subject}="test";
$cd->{Body}="test";
$cd->Send;
print Win32::OLE->LastError();
paulredpath is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:15 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.