hi
Im new to Perl.
Im trying to write a program to send an e-mail via my cgi script. I tried various options - MIME::Lite, Sendmail, Mail::Sender, and none seem to work.
I get no error message in the Server Log file, but I dont receive an e-mail either. I suspect that it cant establish a connection to the SMTP server. Is there a way of knowing what communication happens with the SMTP server. The code I use is as below:
Thanks for your help.
Amy -
#!C:\Perl\bin\perl.exe
-
use CGI::Carp qw(fatalsToBrowser);
-
-
use Mail::Sender;
-
-
use Net::SMTP;
-
-
print "Content-type: text/html\n\n";
-
-
my $relay = "xxx.xxx.edu";
-
my $smtp = Net::SMTP->new($relay)
-
|| die "Can't open mail connection: $!";
-
my $to='xxx\@cs.xxx.edu';
-
my $from='xxx\@cs.xxx.edu';
-
-
$smtp->mail($from);
-
$smtp->to($to);
-
-
$smtp->data();
-
$smtp->datasend("To: $to\n");
-
$smtp->datasend("From: $from\n");
-
$smtp->datasend("Subject: $subject\n");
-
$smtp->datasend("\n");
-
-
foreach $body (@body) {
-
$smtp->datasend("$body\n");
-
}
-
-
$smtp->dataend();
-
$smtp->quit();
-
-
-
-
-
open my $DEBUG, ">> debugfile.txt"
-
or die "Can't open the debug file: $!\n";
-
-
$sender = new Mail::Sender
-
{smtp => 'mail.cs.xxx.edu', from => 'xxx@cs.xxx.edu'};
-
$sender->MailFile({to => 'xxx@cs.xxx.edu',
-
subject => 'Here is the file',
-
msg => "I'm sending you the list you wanted.",
-
debug => $DEBUG,
-
debug_level=>3,
-
authid=>'xxx',
-
authpwd=>'pwd'
-
});
-
$sender->SendEnc;
-
-
$sender->Close;
-
18 8788 Ganon11 3,652
Recognized Expert Specialist
Try Mail::Send; it's the module my professor suggests for e-mailing with Perl. Here's a short sample: - use Mail::Send;
-
my $mail = Mail::Send->new;
-
$mail->to('joe@example.com');
-
$mail->subject('Hey Joe');
-
my $fh = $mail->open();
-
print $fh "Hey Joe, what's up?";
-
$fh->close;
Hi Sirs,
I am using the codes above and it did not work. Used Email::send and not mail::send module as perl package manager did not have that.
Is it smtp or what problem.. Is there any sample? Thanks in advance.
Best Rgds,
Andrew -
-
#!/usr/bin/perl -w
-
#!c:/perl/bin/perl.exe
-
-
-
use Email::Send;
-
my $mail = Mail::Send->new;
-
$mail->to('joe@example.com');
-
$mail->subject('Hey Joe');
-
my $fh = $mail->open();
-
print $fh "Hey Joe, what's up?";
-
$fh->close;
-
-
Html error
========
Internal Server Error
The server encountered an internal error or misconfiguratio n and was unable to complete your request.
Please contact the server administrator, admin@Andrew.so lar and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
apache error log
============
[Thu Dec 11 14:13:52 2008] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified. : couldn't spawn child process: D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/emailsend6.pl
apache access log
=============
127.0.0.1 - - [11/Dec/2008:14:13:51 +0800] "GET /cgi-bin/emailsend6.pl HTTP/1.1" 500 538
perl script testing in perl/bin
=============== =====
C:\Perl\bin>per l -c d:\emailsend6.p l
d:\emailsend6.p l syntax OK
KevinADC 4,059
Recognized Expert Specialist
wrong shebang line?
#!/usr/bin/perl -w
#!c:/perl/bin/perl.exe
the second one should be first, unless you actually have perl installed at usr/bin on your Windows box.
numberwhun 3,509
Recognized Expert Moderator Specialist @happyse27
You need to fix your code. You are calling one module and then specifying another in the constructor: -
use Email::Send;
-
my $mail = Mail::Send->new;
-
My suggestion is to read the Email::Send page at cpan.org and see if they have anything regarding logging.
Regards,
Jeff
Hi all,
This code didnt work either...
same problem of internal server error...
same logs.
kindly advise...
Thanks,
Andrew -
#!c:/perl/bin/perl.exe
-
-
-
-
use Mail::Sender::Easy qw(email);
-
-
-
-
email({
-
-
'from' => 'andrew@inovaventure.com',
-
-
'to' => 'happse@hotmail.com',
-
-
'cc' => 'your_pal@ddre.ss',
-
-
'subject' => 'Perl is great!',
-
-
'priority' => 2, # 1-5 high to low
-
-
'confirm' => 'delivery, reading',
-
-
'smtp' => '192.168.2.111',
-
-
'port' => 26,
-
-
'auth' => 'LOGIN',
-
-
'authid' => 'andrew',
-
-
'authpwd' => 'andrew2100',
-
-
'_text' => 'Hello *World* :)',
-
-
'_html' => 'Hello <b>World</b> <img src="cid:smile1" />',
-
-
'_attachments' => {
-
-
'smiley.gif' => {
-
-
'_disptype' => 'GIF Image',
-
-
'_inline' => 'smile1',
-
-
'description' => 'Smiley',
-
-
'ctype' => 'image/gif',
-
-
'file' => '/home/foo/images/smiley.gif',
-
-
},
-
-
'mydata.pdf' => {
-
-
'description' => 'Data Sheet',
-
-
'ctype' => 'application/pdf',
-
-
'msg' => $pdf_guts,
-
-
},
-
-
},
-
-
}) or die "email() failed: $@";
-
eWish 971
Recognized Expert Contributor
You are missing some important data here. - use strict;
-
use warnings;
These are essential because the error you are saying is to vague. It could be many different things that are causing it. Without some error checking and syntax checking it is that much harder. Read this for some potential help for your problem.
--Mork
hi Sir,
The below code is working well as minimal codes... cheers...
Btw, how do I find free public smtp server since this is internal server ip with vpn??
Thanks again,
Andrew -
-
#!c:/perl/bin/perl.exe -w
-
-
use strict;
-
use warnings;
-
-
use Mail::Sender::Easy qw(email);
-
-
print "Content-type: text/plain\n\n";
-
-
-
email({
-
#from email address need to change
-
'from' => 'andrew@inova.com',
-
'to' => 'happse@hotmail.com',
-
'cc' => 'your_pal@ddre.ss',
-
'subject' => 'Perl is great!',
-
'priority' => 2, # 1-5 high to low
-
'confirm' => 'delivery, reading',
-
'smtp' => '192.168.2.111',
-
'port' => 25,
-
#'auth' => 'LOGIN',
-
'authid' => 'andrew@inovaventure.com',
-
'authpwd' => 'andrew2100',
-
'_text' => 'Hello *World* :)',
-
#'_html' => 'Hello <b>World</b> <img src="cid:smile1" />',
-
#'_attachments' => {
-
#'smiley.gif' => {
-
#'_disptype' => 'GIF Image',
-
#'_inline' => 'smile1',
-
#'description' => 'Smiley',
-
#'ctype' => 'image/gif',
-
#'file' => '/home/foo/images/smiley.gif',
-
#},
-
#'mydata.pdf' => {
-
#'description' => 'Data Sheet',
-
#'ctype' => 'application/pdf',
-
#'msg' => $pdf_guts,
-
#},
-
#},
-
}) or die "email() failed: $@";
-
-
Hi All,
This is the more complete codes with attachment sent successfully... Cheers...
Thanks,
Andrew -
#!c:/perl/bin/perl.exe -w
-
-
use strict;
-
use warnings;
-
-
use Mail::Sender::Easy qw(email);
-
-
print "Content-type: text/plain\n\n";
-
-
-
email({
-
'from' => 'andrew@inovaventure.com',
-
'to' => 'happse@hotmail.com',
-
'cc' => 'your_pal@ddre.ss',
-
'subject' => 'Perl is great!',
-
'priority' => 2, # 1-5 high to low
-
'confirm' => 'delivery, reading',
-
'smtp' => '192.168.2.111',
-
'port' => 25,
-
#'auth' => 'LOGIN',
-
'authid' => 'andrew',
-
'authpwd' => 'andrew2100',
-
'_text' => 'Hello *World5* :)',
-
'_html' => 'Hello <b>World</b> <img src="cid:smile1" />',
-
'_attachments' => {
-
'smiley.gif' => {
-
'_disptype' => 'GIF Image',
-
'_inline' => 'smile1',
-
'description' => 'Smiley',
-
'ctype' => 'image/gif',
-
'file' => 'D:/program files/Apache Software
-
-
Foundation/Apache2.2/htdocs\smiley.gif',
-
},
-
#'mydata.pdf' => {
-
#'description' => 'Data Sheet',
-
#'ctype' => 'application/pdf',
-
#'msg' => $pdf_guts,
-
#},
-
},
-
}) or die "email() failed: $@";
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: mhawkins19 |
last post by:
I have a form built and on the onclick event I validate all of the
fields and then if the form is ok, on the submit event I run a
javascript function to set a cookie and download a file from the
current window.
I have a cgi script provided by my web host to send the contents of the
form through email but they only show me how to use the cgi script to
send email through the submit event of the form.
ie. <form name="downloadform"...
|
by: Bob Jones |
last post by:
We have developed a commercial ASP.net application
(personal nutrition management and tracking); we want to
send smtp email from within it.
For our development box, we use WinXP Pro, IIS 5.5,
VisualStudio2002, VB as programing language. Our
test/development version of the web app as hosted on
our "localhost" works fine; our "Default SMTP Virtual
Server" is running (per the IIS console).
|
by: Ron |
last post by:
hi guys,
I am trying to send email using smtpMail.
I can send emails inside the organization, but out of the organization I get
an error "The server rejected one or more recipient addresses. The server
response was: 550 5.7.1 Unable to relay for ........"
now I tried to add username and password for the server to relay but it is
still not working.
this is the example i used:
|
by: Gerard |
last post by:
Hello
I have created a windows service to monitor a database, it starts some
checks when a timer elapses. The checks send emails depending on their
findings. My issue is that when I created a windows application it
worked fine, however I need to use a service as I don't want to rely
on a user being logged in. The errors I get are:
Index #:System.Web.HttpException: Could not access 'CDO.Message'
object. --->...
|
by: ucasesoftware |
last post by:
i start a process to send email via Outlook
I have succes to build the email text, objet, sender...
but i want to automate the "send"...
i don't want my users to click on Send email button...
is it possible ?
| |
by: =?Utf-8?B?SHVnaA==?= |
last post by:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused and please help.
Thanks in advance.
Hugh
|
by: =?Utf-8?B?Q2hlZg==?= |
last post by:
I can use outlook2003 to send email,but I cann't use this code below to send
email.
Please help me to test this code and instruct me how to solve this problem
in detail.
software environment: VS2005 + XP.-- I have disabled firewall
hardware enviornmnet:telcom's modem connects hub,hub connects two
computers.。-- I also tried to connect computer to modem directly,but I can
|
by: Cecil1984 |
last post by:
hi guys,
could any one help me how to write perl script to send email in unix system.
thank you for any helping.
|
by: shailendra deshpande |
last post by:
right now i have only pain html page.and i want to send email through
it using javascript
plz. anybody tell me how to send email from plain html page using
javascript.
thanks in advance
Shailendra Deshpande
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |