Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > SendMail Problem

Reply
Thread Tools

SendMail Problem

 
 
jim
Guest
Posts: n/a
 
      10-25-2003

Hello,

I am having a problem w/SendMail reporting: "No recipient addresses
found in header".

Funny thing is though, I properly recieve the email message.

What do I need to change to stop recieving the error message in my
browser?

Thanks for your help.

-jim



Here is the code:


sub my_send_mail
{
local($fromuser, $touser, $subject, $messagebody) = @_;

local($old_path) = $ENV{"PATH"};


$ENV{"PATH"} = "";
$ENV{ENV} = "";

open(SENDMAIL, "| /bin/sendmail -t -n") || &web_error ("Unable to open
sendmail");

$ENV{"PATH"} = $old_path;

print SENDMAIL "To: $touser\n";
print SENDMAIL "From: $fromuser\n";
print SENDMAIL "Subject: $subject\n\n";
print SENDMAIL "$messagebody\n";
close(SENDMAIL);

}

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      10-25-2003
jim <defenderjim4@no_dam_spam_juno.com> wrote:


> I am having a problem w/SendMail



I can't help with that part, other than checking for
newlines in the arguments.


> sub my_send_mail
> {
> local($fromuser, $touser, $subject, $messagebody) = @_;



You should always prefer lexical (my) variables over dynamic (local)
variables, except when you can't.


my($fromuser, $touser, $subject, $messagebody) = @_;

die "newlines in address" if grep /\n/, $fromuser, $touser;


> local($old_path) = $ENV{"PATH"};
> $ENV{"PATH"} = "";
> $ENV{ENV} = "";



Why are you changing environment variables?

Do you have taint checking turned on or something?


> close(SENDMAIL);



You should be checking the return value from close() as well
as from open().


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      10-25-2003
jim wrote:
> I am having a problem w/SendMail reporting: "No recipient addresses
> found in header".
>
> Funny thing is though, I properly recieve the email message.
>
> What do I need to change to stop recieving the error message in my
> browser?


Don't know. Whatever the reason is, it has probably nothing to do with
the part of the code you posted.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
jim
Guest
Posts: n/a
 
      10-26-2003
Hey,

>I can't help with that part, other than checking for

Well, that was it.
Thank you for the input.


Now the weird part is that I am receiving two email messages.
I am only sending one. Very strange.


>You should always prefer lexical (my) variables over dynamic (local)
>variables, except when you can't.

Yep, you certainly are correct. <lame excuse>...Long story.... Legacy
code I inherited... Under time pressure to be done w/this project.</lame
excuse>


> my($fromuser, $touser, $subject, $messagebody) = @_;
> die "newlines in address" if grep /\n/, $fromuser, $touser;

Made changes to code.

> $ENV{ENV} = "";
> Do you have taint checking turned on or something?

Yes.

 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      10-26-2003
On Sat, 25 Oct 2003 21:29:19 GMT
jim <defenderjim4@no_dam_spam_juno.com> wrote:
> I am having a problem w/SendMail reporting: "No recipient addresses
> found in header".
>
> Funny thing is though, I properly recieve the email message.
>
> What do I need to change to stop recieving the error message in my
> browser?

<snip>

Have you considered using the many email modules available in Perl?

I know this doesn't directly answer your question, but I find this a
rather poor way to send email. It's not portable and relies upon
_you_ to check for errors, know how to pass parameters to the
executing application (in this case, sendmail), and it makes for a
nightmare for maintainence. But, that's all just my opinion

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Twenty Percent of Zero is Better than Nothing. -- Walt Kelly

 
Reply With Quote
 
jim
Guest
Posts: n/a
 
      10-26-2003
James,

> Have you considered using the many email modules available in Perl?
> I know this doesn't directly answer your question, but I find this a

No, have not considered this. I am an experienced programmer, but very new
to Perl. I am just trying to get code working that I was given, so I have
tended to look at the leafs, not the forest.

Suggestions?

Thanks for the info.

-jim
 
Reply With Quote
 
Tore Aursand
Guest
Posts: n/a
 
      10-26-2003
On Sun, 26 Oct 2003 15:42:40 +0000, jim wrote:
>> Have you considered using the many email modules available in Perl?


> No, have not considered this. [...] Suggestions?


MIME::Lite.


--
Tore Aursand <>
 
Reply With Quote
 
David Efflandt
Guest
Posts: n/a
 
      10-27-2003
On Sun, 26 Oct 2003 04:21:12 GMT, jim <defenderjim4@no_spam_juno.com> wrote:
> Hey,
>
>>I can't help with that part, other than checking for

> Well, that was it.
> Thank you for the input.
>
>
> Now the weird part is that I am receiving two email messages.
> I am only sending one. Very strange.


I suspect your $touser is not formatted properly. Is it in single or
double quotes? If in double quotes, did you escape the @? Does it
contain anything other than e-mail address (real name)?

>>You should always prefer lexical (my) variables over dynamic (local)
>>variables, except when you can't.

> Yep, you certainly are correct. <lame excuse>...Long story.... Legacy
> code I inherited... Under time pressure to be done w/this project.</lame
> excuse>
>
>
>> my($fromuser, $touser, $subject, $messagebody) = @_;
>> die "newlines in address" if grep /\n/, $fromuser, $touser;

> Made changes to code.
>
>> $ENV{ENV} = "";
>> Do you have taint checking turned on or something?

> Yes.
>



--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      10-27-2003
On Sun, 26 Oct 2003 15:42:40 GMT
jim <defenderjim4@no_spam_juno.com> wrote:

> James,
>
> > Have you considered using the many email modules available in
> > Perl? I know this doesn't directly answer your question, but I
> > find this a

> No, have not considered this. I am an experienced programmer, but
> very new to Perl. I am just trying to get code working that I was
> given, so I have tended to look at the leafs, not the forest.
>
> Suggestions?


Net::SMTP is a good one. So is MIME::Lite.
Mail::Mailer, if I not mistaken, comes with the standard with Perl.

Visit http://search.cpan.org/ . There, you can search for email
modules and read the documentation before using the modules - which is
something I highly recommend before using them; or even installing
them. If I can follow the documentation _before_ installing the
module, then chances are I can use the module successfully.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
What I tell you three times is true.

 
Reply With Quote
 
Andrew Rich \(VK4TEC\)
Guest
Posts: n/a
 
      10-27-2003
#!/usr/bin/perl
use Net::SMTP;
$from = '';
$to = '';
$subject = 'Updated web site';
$smtp = Net::SMTP->new('smtp.dogo.com.au',Debug=>0);
$smtp->mail($email);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $email\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("Date: Sun, 12 Oct 2003 10:55:55 -0500\n");
$smtp->datasend("www.software.net\n");
$smtp->dataend();
sleep 5;
print "$email\n";
$smtp->quit;



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [sendmail,perl] How to catch a mailer error [perl script as sendmail.cf mailer] Andrzej Adam Filip Perl 0 03-31-2008 09:24 PM
Unable to load tag handler class "com.cj.smtp.Sendmail" for tag "send:Sendmail" sugapablo Java 0 09-21-2007 01:41 PM
Mailman - Sendmail problem swangdb Python 3 08-21-2006 07:45 PM
Urgent SendMail Problem Andrea Williams ASP .Net 7 12-13-2004 06:05 PM
Sendmail problem jim Perl 4 10-30-2003 06:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57