[Xitami] Getting Xitami to Mail Through A CGI Script?

R O xitami@lists.xitami.org
Tue, 25 Nov 2003 16:18:23 -0800


Heres the CGI code you need for a windows machine.  For clarification, 
Xitami doesn't actually interact with email unless you are using something 
special I don't know about.  To use CGI you would use perl scripts designed 
for a Unix or Windows platform....the code below is for a windows 
environment and requires you to have loaded the Net package from the 
activestate perl libraries, use the command line PPM program (found in 
/perl/bin) to install additional modules and packages.  (PPM>> install 
libnet).

Hope it helps.

#! /perl/bin/perl
#### Needed to actually communicate with any SMTP server
use Net::SMTP ;
#### Needed to retrieve FORM info regardless if its a GET or POST
use CGI ;
$query = new CGI ;

#### values passed in from any standard HTML form, either post or get
#### These values are NOT being used in the script below
$subject = $query->param('subject') ;
$fromAdd = $query->param('fromAdd') ;
$toAdd = $query->param('toAdd') ;

### Get date and time if you want to include it the CONTENT BODY of the 
email
### very simple getDate
   $sec = (localtime)[0] ;
   $min = (localtime)[1] ;
   $hour = (localtime)[2] ;
   $day = (localtime)[3] ;
   $mon = (localtime)[4] + 1 ;
   $year = (localtime)[5] + 1900 ;

###### OR preassemble the date.
   $curDate = (localtime)[5] + 1900) . "-" . ((localtime)[4] + 1) . "-" . 
(localtime)[3] ;
   $curTime = (localtime)[2] . ":" . (localtime)[1] . ":" . (localtime)[0] ;

### connect to SMTP server
   $smtp = Net::SMTP->new(desired.mailserver.com, Debug => 1,) or die "can't 
connect to server $!" ; ### specify FROM address
   $smtp->mail("blah\@blah.com") ;
### specify TO address
   $smtp->to("xitami\@lists.xitami.org") ;
### Start data string
   $smtp->data() ;  # Start the mail

### this section mimicks the header info the user actually sees. (its 
actually just data though)
   $smtp->datasend("To: xitami\@lists.xitami.org\n") ;
   $smtp->datasend("From: blah\@blah.com\n") ;
   $smtp->datasend("Subject: Xitami CGI SMTP interaction\n") ;

### next section commented out but would allow you to send HTML formatted 
emails (still just data)
   #$smtp->datasend("\nMIME-Version: 1.0") ;
   #$smtp->datasend("\nContent-Type: text/html\;") ;
   #$smtp->datasend("\n	charset=\"iso-8859-1\"") ;
   #$smtp->datasend("\nContent-Transfer-Encoding: quoted-printable") ;
   #$smtp->datasend("\nX-MimeOLE: Produced By Microsoft MimeOLE 
V5.50.4522.120") ;

### here is the CONENT of your email (still just data)
   $smtp->datasend("\nJust send info all day long") ;
   $smtp->datasend("\nJust send info all day long") ;
   $smtp->datasend("\nJust send info all day long") ;
   $smtp->datasend("\nJust send info all day long") ;
   $smtp->datasend("\nJust send info all day long") ;
   $smtp->datasend("\nJust send info all day long") ;
   $smtp->datasend("\n.........") ;

### finish sending the DATA portion and transmit email
   $smtp->dataend() ;

### close SMTP Session
   $smtp->quit ;

#### end perl script


Russel P. Olinger
rolinger1@hotmail.com

>From: "patricko" <polson1@adelphia.net>
>Reply-To: xitami@lists.xitami.org
>To: <xitami@lists.xitami.org>
>Subject: Re: [Xitami] Getting Xitami to Mail Through A CGI Script?
>Date: Tue, 25 Nov 2003 16:42:43 -0700
>
>SYNOPSIS
>
>   use Mail::Sendmail;  %mail = ( To      => 'you@there.com',
>             From    => 'me@here.com',
>             Message => "This is a very short message"
>            );  sendmail(%mail) or die $Mail::Sendmail::error;  print "OK.
>Log says:\n", $Mail::Sendmail::log;sendmail for windows I don't think is
>available anymore you can modify the script to use mail-sendmail tryppm
>install mail-sendmailsee if you can get that to work should be simple
>changes----- Original Message -----
>From: "Dan Baerg" <highvelocityhosting@hotmail.com>
>To: <xitami@lists.xitami.org>
>Sent: Tuesday, November 25, 2003 3:40 PM
>Subject: [Xitami] Getting Xitami to Mail Through A CGI Script?
>
>
>| Hello Fellow Subscribers
>|
>|     I'm using Xitami on a Windows Machine and was wondering how to get a
>CGI
>| Script that was made for Unix and used sendmail to work with Xitami?? I'd
>| actually like the script to mail through an SMTP Server on another 
>Windows
>| Machine. Any Suggestions out there??
>|
>| Thanks
>|
>| Dan
>|
>| _________________________________________________________________
>| MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
>|
>http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>|
>|
>| --
>| Xitami Users Mailing List -- For Xitami support
>| To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
>
>
>
>--
>Xitami Users Mailing List -- For Xitami support
>To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami

_________________________________________________________________
Set yourself up for fun at home!  Get tips on home entertainment equipment, 
video game reviews, and more here.   
http://special.msn.com/home/homeent.armx