![]() |
|
|
#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 |
|
|
|
|
|
#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 Errorwhich 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! |
|
|
|
|
|
#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 win32
le module installed??Your help is appreciated :-) Last edited by Bilsdale; 09-11-2007 at 03:13 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 %> |
|
|
|
|
|
#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? |
|
|
|
|
|
#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 ErrorIn 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;Thanks in anticipation of your ongoing help :-) Last edited by Bilsdale; 10-12-2007 at 01:39 PM. |
|
|
|
|
|
#14 (permalink) |
|
Bring me your problems :p
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(); |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|