Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems using sendmail from Perl script

44 views
Skip to first unread message

Peter Mellen

unread,
Oct 19, 1995, 3:00:00 AM10/19/95
to
I am trying to write a Perl script which sends information collected
from an HTML form to my email address. Unfortunately, I am having a
lot of trouble. The script executes without reporting any errors, but
I never receive any mail!

Can someone tell me what I'm doing wrong? The sendmail section of my
script follows:

open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $FORM{'email'} ($FORM{'contact'})\n";
print MAIL "Subject: TVC Web Information (Forms submission)\n\n";
print MAIL "Name: $FORM{'contact'} \n";
print MAIL "E-Mail Address: $FORM{'email'}\n";
print MAIL "Company: $FORM{'company'}\n";
print MAIL "Address:\n";
print MAIL " $FORM('Addr1')\n";
print MAIL " $FORM('Addr2')\n";
.
.
.
\/
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);

$mailprog is set to "/bin/usr/sendmail", which is where sendmail
resides on the web server. $recipient is set to
"pme...@teamvision.com", which is my mail address.

I appreciate any help anyone can provide. I think it has something to
do with the way I'm using sendmail, but I haven't been able to find
any sendmail documentation.
======================
Peter Mellen
Team/Vision Consulting
3221 M Street, NW
Washington, DC 20007
202-298-6520 Voice
202-232-3006 Fax
======================


Lawrence Garfield

unread,
Oct 19, 1995, 3:00:00 AM10/19/95
to
On 19 Oct 1995, Mike Heins wrote:

> hed...@best.com (M. Hedlund) writes:
<cut>


> >>The script executes without reporting any errors, but
> >> I never receive any mail!

I'm getting the same problem. The process reports that the mail has
been sent, but I'm not believing it anymore.

> >Try inserting
> > print MAIL "To: $recipient\n";
> >before the Subject.
>
> I believe that $mailprog will have to be defined as '/usr/lib/sendmail -t'
> for this to work. The -t option has sendmail read the To: address from the
> message. The order should not matter.

I believe that my code fulfills these recommendations. Also, we have
/user/sbin/sendmail, also with the -t option. Here's my code:

$webmaster = "el...@cais.com";
<cut>
open (MESSAGE, "| /usr/sbin/sendmail -t") || die "Can't open mail program.";

# Format email header information

print MESSAGE "To: $webmaster\n";
print MESSAGE "From: $ENV{'REMOTE_ADDR'}\n";
print MESSAGE "Reply-To: $FORM{feed_email}\n";
print MESSAGE "Subject: $subject\n\n";

# Write the actual email message

print MESSAGE "Answer from $FORM{feed_name} <$FORM{feed_email}>:\n\n";
print MESSAGE "$FORM{feed_comments}\n";
close (MESSAGE);


Lawrence Garfield

unread,
Oct 20, 1995, 3:00:00 AM10/20/95
to
On 19 Oct 1995, Mike Heins wrote:

> hed...@best.com (M. Hedlund) writes:
<cut>
> >>The script executes without reporting any errors, but
> >> I never receive any mail!

I'm getting the same problem. The process reports that the mail has
been sent, but I'm not believing it anymore.

> >Try inserting
> > print MAIL "To: $recipient\n";
> >before the Subject.
>
> I believe that $mailprog will have to be defined as '/usr/lib/sendmail -t'
> for this to work. The -t option has sendmail read the To: address from the
> message. The order should not matter.

I believe that my code fulfills these recommendations. Also, we have

/user/sbin/sendmail, also with the -t option. (BTW, I know that the
forms data including sender and recipient are being read by the script
because I can print out the values, so it's not a problem with the
form, as far as I can tell.)

Here's my code:

--- begin ---

$webmaster = "el...@cais.com";
<cut>
open (MESSAGE, "| /usr/sbin/sendmail -t") || die "Can't open mail program.";

# Format email header information

print MESSAGE "To: $webmaster\n";
print MESSAGE "From: $ENV{'REMOTE_ADDR'}\n";
print MESSAGE "Reply-To: $FORM{feed_email}\n";
print MESSAGE "Subject: $subject\n\n";

# Write the actual email message

print MESSAGE "Answer from $FORM{feed_name} <$FORM{feed_email}>:\n\n";
print MESSAGE "$FORM{feed_comments}\n";
close (MESSAGE);

--- end ---

Lawrence Garfield
el...@cais.com
http://www.cais.com/elgar/home.htm

Prakash Baskaran

unread,
Oct 21, 1995, 3:00:00 AM10/21/95
to pme...@teamvision.com
Everything looks good except for one thing. You forgot to finish the
mail by printing a 'dot'.

Before closing your mail with close (MAIL), add the line

print MAIL ".";

prakash

Randal L. Schwartz

unread,
Oct 21, 1995, 3:00:00 AM10/21/95
to
>>>>> "Prakash" == Prakash Baskaran <pra...@mars.superlink.net> writes:

Prakash> Everything looks good except for one thing. You forgot to finish the
Prakash> mail by printing a 'dot'.

Prakash> Before closing your mail with close (MAIL), add the line

Prakash> print MAIL ".";

Uh, no.

Dot is only required when you are talking SMTP, and then you use the
"dot == end, double-dot == dot" encoding convention. Not necessary
at all when you are talking to sendmail.

Just another sendmail-guru and web-head,

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <mer...@stonehenge.com> Snail: (Call) PGP-Key: (finger mer...@ora.com)
Web: <A HREF="http://www.teleport.com/~merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me

Otis Gospodnetic

unread,
Oct 23, 1995, 3:00:00 AM10/23/95
to
Lawrence Garfield (el...@cais.cais.com) wrote:
> On 19 Oct 1995, Mike Heins wrote:

> > hed...@best.com (M. Hedlund) writes:
> <cut>
> > >>The script executes without reporting any errors, but
> > >> I never receive any mail!


why not use something that already works ?
ftp://ftp.middlebury.edu/pub/WWW/Web2Mail/
get it, it takes 60 seconds to configure it and run it.
successfuly, too.

Otis

> Here's my code:

> --- begin ---

> --- end ---


--
Men rule the World !
Women rule men.

Stan Shapiro

unread,
Oct 23, 1995, 3:00:00 AM10/23/95
to M. Hedlund, el...@cais.com
>> > hed...@best.com (M. Hedlund) writes:
>> <cut>
>> > >>The script executes without reporting any errors, but
>> > >> I never receive any mail!
>
>
Hello,
Did you find an answer to this ? Sorry I've been busy recently and
not seen much of the news. I was wondering if adding the '-n'
switch might help.

A very wild guess that comes to
mind is that $REMOTE_ADDR is not a valid email address (it's an IP
address) so maybe sendmail tacks on a hostname (it wouldnt just break
would it?) and that without
-n some sort of aliasing may be taking place that takes you off the
recipient list. just a guess,though

Hope this maybe helps,

All the Best.
Stan Shapiro
--


>why not use something that already works ?
>ftp://ftp.middlebury.edu/pub/WWW/Web2Mail/
>get it, it takes 60 seconds to configure it and run it.
>successfuly, too.
>
>Otis
>
>> I'm getting the same problem. The process reports that the mail has

James A. Hoagland

unread,
Oct 23, 1995, 3:00:00 AM10/23/95
to
Otis Gospodnetic (ot...@panther.middlebury.edu) wrote:
: Lawrence Garfield (el...@cais.cais.com) wrote:
[...]
: why not use something that already works ?

: ftp://ftp.middlebury.edu/pub/WWW/Web2Mail/
: get it, it takes 60 seconds to configure it and run it.
: successfuly, too.

You can also use Getcomments to send e-mail. In addition you can append to
a file, and display text or and arbitary URL back to the user.

<URL:http://seclab.cs.ucdavis.edu/~hoagland/getcomments/>

Jim Hoagland

--
|* James A. Hoagland, Research Assistant, Computer Security Lab *|
|* University of California, Davis Department of Computer Science *|
|* <URL:http://seclab.cs.ucdavis.edu/~hoagland/> *|
|* Commit random acts of kindness and senseless acts of beauty. *|

luca...@nettuno.it

unread,
Oct 25, 1995, 3:00:00 AM10/25/95
to
Hi,
Which is the standard way to attach a file when sending E-mail from
a script???

I'm trying:

$sub="whatever!";


open (M, "| /usr/bin/mailx -s \"$sub\" $address <anyfile.xyz");

I do receive the file but directly in the body of the message (

any print M "blah blah"; gives no mail output).

Also how to include/attach more then one file?

THANKS.

Vassilis T.

unread,
Oct 26, 1995, 3:00:00 AM10/26/95
to hed...@best.com, el...@cais.cais.com
In article <Pine.BSI.3.91.951020...@cais3.cais.com>,

Lawrence Garfield <el...@cais.cais.com> wrote:
>On 19 Oct 1995, Mike Heins wrote:
>
>> hed...@best.com (M. Hedlund) writes:
[...]

>$webmaster = "el...@cais.com";
> <cut>
> open (MESSAGE, "| /usr/sbin/sendmail -t") || die "Can't open mail
program.";

Try "/usr/sbin/sendmail $webmaster" - it should work :)

Vassilis

+-----------------------------------------------------------------+
| Vassilis Terzopoulos : I am not young enough to know everything.|
| bac...@eexi.gr & b...@techlink.gr & vt...@leon.nrcps.ariadne-t.gr |
| http://www.eexi.gr/~bacardi - working at http://www.techlink.gr |
| * This is MY OWN opinion, not my employer's nor anyone else's * |
+-----------------------------------------------------------------+
No answer is also an answer.

0 new messages