Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send mail directly to SMTP??

Status
Not open for further replies.

Wullie

Programmer
Mar 17, 2001
3,674
GB
Hi,

What I am trying to do is to submit a form on a windows server but I need to send the data directly from submittal of the form to a smtp server. I have been asked by a friend to do this but I cannot use sendmail.

Can anyone help?? Please..

Thanks in advance Wullie

 
There is a module on CPAN called Mail-Sendmail-0.78. The 'readme' says all it needs it Perl5 and a network connection. I've never tried it, but it sounds like it might do what you need. If not, I'm sure a little surfing on or would be fruitful.

HTH If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.
 
Thanks,

As far as I am led to believe, sendmail is not compatible with windows, at least not with ME anyway.

I have found a few windows substitutes, but the documentation for most is a little over my head and the prices for some are even worse.

I will take a look at CPAN.

Thanks for both of your time

Wullie

 
BLAT is purported to be THE windows replacement for sendmail. Never used it, but hear about it a lot.

You can probably also find a native SMTP interface library for perl at CPAN. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Hi,

Sorry I took so long to reply. I've been really busy..

I took a quick look at blat when I decided to try this but most of the documentation was about sending mail from the command line, I've not really had time to study it..

I have in the past run some scripts on an apache server on my local machine I use for testing purposes and they send mail directly to an smtp server without me having sendmail or blat installed...

One of the scripts in question is Yabb forums.
I set it up to test it before introducing it to the server the site is on and it has an option to send directly to smtp, it works fine without any external mail program.

I was hoping that someone on here had a suggestion on how to do it without blat etc but it looks as though blat is the way to go..

If anyone has any other suggestions I would really like to hear them..

Thanks a lot for all your help, I really appreciate it..

Wullie

 
Try using Net::SMTP from CPAN. Such as below:

#!/usr/bin/perl
use Net::SMTP;

### CGI code goes here to get the form fields ###

mail_send($mailto,$from,$to,$subject,$msg);


# Name: mail_send
# Args: mailto .... to whom this mail is going to
# from ...... the contents of the from field
# to ........ the contents of the to field
# subject ... the contents of the subject field
# msg ....... the message to send

sub mail_send {
my ($mailto,$from,$to,$subject,$msg) = @_;

my $mailhost = "mail.myserver.co.uk"; # change this to your mail server
my $smtp = new Net::SMTP($mailhost);

$smtp->mail($ENV{USER});
$smtp->to($mailto);

$smtp->data();
$smtp->datasend("From: $from\n");
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("$msg");
$smtp->dataend();
$smtp->quit;

return 0;
}

HTH,
Barbie.
Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top