SendMail Problem

Discussion in 'Perl Misc' started by jim, Oct 25, 2003.

  1. jim

    jim Guest

    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);

    }
     
    jim, Oct 25, 2003
    #1
    1. Advertising

  2. 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
     
    Tad McClellan, Oct 25, 2003
    #2
    1. Advertising

  3. 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
     
    Gunnar Hjalmarsson, Oct 25, 2003
    #3
  4. jim

    jim Guest

    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.
     
    jim, Oct 26, 2003
    #4
  5. 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
     
    James Willmore, Oct 26, 2003
    #5
  6. jim

    jim Guest

    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
     
    jim, Oct 26, 2003
    #6
  7. jim

    Tore Aursand Guest

    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 <>
     
    Tore Aursand, Oct 26, 2003
    #7
  8. 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/
     
    David Efflandt, Oct 27, 2003
    #8
  9. 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.
     
    James Willmore, Oct 27, 2003
    #9
  10. #!/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;
     
    Andrew Rich \(VK4TEC\), Oct 27, 2003
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jim

    Sendmail problem

    jim, Oct 24, 2003, in forum: Perl
    Replies:
    4
    Views:
    663
  2. Andrea Williams

    Urgent SendMail Problem

    Andrea Williams, Dec 9, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    1,871
    Andrea Williams
    Dec 13, 2004
  3. swangdb

    Mailman - Sendmail problem

    swangdb, Aug 21, 2006, in forum: Python
    Replies:
    3
    Views:
    683
    swangdb
    Aug 21, 2006
  4. sugapablo
    Replies:
    0
    Views:
    2,162
    sugapablo
    Sep 21, 2007
  5. Andrzej Adam Filip
    Replies:
    0
    Views:
    4,097
    Andrzej Adam Filip
    Mar 31, 2008
Loading...

Share This Page