Solved

Requesting CGI script with just the mail command, for IIS, using SMTP mail

Posted on 2004-09-02
7
876 Views
Last Modified: 2008-01-09
May I please have an example of CGI/Perl code that sends mail on IIS?  Assume constants for the email address, subject, etc.  This is for an IIS environment, using SMTP mail.
0
Comment
Question by:thievesguild
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:suramsureshbabu
Comment Utility
0
 

Author Comment

by:thievesguild
Comment Utility
Thank you suramsureshbabu.  Unfortunately most of those examples are for Unix, I believe.  I'm looking for an IIS example.
0
 
LVL 4

Expert Comment

by:rduke15
Comment Utility
The Perl module Mail::Sendmail (http://alma.ch/perl/mail.html) is not Unix-specific. All it needs is Perl and an SMTP server. Works flawlessly on MS IIS if you have Perl installed.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:thievesguild
Comment Utility
Thank you for your reply, rduke.  I'm learning that the directory structure lines in Sendmail do not necessarily indicate that they are specific to Unix-Linux.  

However, I was hoping to get simple CGI commands.  Does CGI have the equivalent for the ASP following?

ASP
Set NewMailObj=Server.CreateObject("CDONTS.NewMail")
NewMailObj.From = "from@address.com"
NewMailObj.To = "to@address.com"
NewMailObj.Subject = "email subject"
NewMailObj.Body = "email body"
NewMailObj.Send

0
 
LVL 4

Expert Comment

by:rduke15
Comment Utility
With CGI, you call some program on the server, which prints out HTML, and the web server sends that HTML to the client browser. The program itself can be anything the server is able to run: some compiled executable, or any script for the language of which the server has an interpreter.

With ASP (like with PHP and others), you call some HTML file which has embedded programming commands. The server reads the file, sends the plain HTML bits directly back to the browser, sends the scripted bits to the interpreter which gives some HTML back, which is then sent to the client browser. ASP is mostly used with VBscript on Microsoft IIS servers, even though it can also be used with Perl, and I understand there are ASP or ASP-like implementations on Unix.

So if you want some VBscript under ASP and Microsoft IIS, that's not CGI, and your best bet would seem to be to ask in a dedicated Microsoft/ASP forum.

If you want to try out CGI, try it at the commmand line first; once it works there and does what you want, it should be easy to have the web server run it.

About the Mail::Sendmail module, it requires you to write a Perl script to use it,  so you have to know (at least some) Perl.

As for the others, that were suggested by suramsureshbabu, they all seem to be relying on the Unix sendmail executable to do the actual mailing, so that wouldn't be portable. Besides, at first glance, they all seem ancient and insecure.

Good luck.
0
 

Author Comment

by:thievesguild
Comment Utility
Thank you for your reply, rduke15.  I suspect I'm using the wrong terms.  I do understand that I need to write Perl with CGI.  Everyone seems to imply there is a way to simply send mail on a web server that has SMTP configured, but I can never get a simple code example that doesn't require a module.

Is this a waste of time?
0
 
LVL 4

Accepted Solution

by:
rduke15 earned 350 total points
Comment Utility
It IS simple if you know some Perl (if you don't, it's fun to learn anyway; try "Programming Perl").

And yes, most scripts these days rely on various modules for common tasks (why re-invent the wheel?). Personally, I use sendform.cgi (http://alma.ch/perl/scripts.html), but there are tons of other similar scripts.

If you are trying to do CGI scripting in Perl without any Perl module, then yes, that definitely would be a waste of time. :-)

BTW, have you already typed things like "perldoc Some::Module", "perldoc -f  somefunction", perldoc somescript.pl", etc. at the command line? If you haven't, start with "perldoc perldoc" and "perldoc perl".

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Read about why website design really matters in today's demanding market.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now