#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    MAIL::SENDMAIL - Inserting $variable Into TO or FROM?


    I'm using the following code to send messages:
    sub send_mail {

    use HTML::Entities;
    use Mail::Sendmail 0.79; # doesn't work with v. 0.74!
    $FORM {'Message'}="GOOD MORNING!! It looks as if things are working!!"
    +;
    $Message="$FORM{'Message'}";
    $FORM{'Sender'}="My Organization";
    $sender="$FORM{'Sender'}";
    $html = <<END_HTML;
    <p><strong>A MESSAGE FROM SOMEBODY</strong>

    <p>$FORM{'Sender'} has sent you a message.</p>
    <p>$Message</p>

    END_HTML
    %mail = (
    To => 'somebody@somewhere.com',
    From => 'me@mysight.com'
    subject => 'A Message From Somebody',
    'content-type' => 'text/html; charset="iso-8859-1"',

    );

    $mail{body} = <<END_OF_BODY;
    <html>$html</html>
    END_OF_BODY
    sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";
    }

    [download]

    This works perfectly when email addresses are entered directly into the TO/FROM entities. However, I want to insert a $variable from a form into those slots. I have tried every combination that I can think of to accomplish that but nothing has worked. Can someone provide some guidance? Thanks for any assistance. I have tried the following at TO and FROM: TO => $VAR,
    TO => "$VAR",
    TO => '$VAR',
    TO => $FORM{'recipient'},
    TO => $FORM{recipient},
    TO => "$FORM{'recipient}",
    TO => "$FORM{recipient}",

    [download]

    All without success.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    832
    Rep Power
    496
    Hmm, this is cross-posted on Perl Monks (http://www.perlmonks.org/?node_id=1071496). There is nothing wrong with cross-posting per se, but it is usually considered much better to state this upfront, so as to avoid duplicate works on various sites.

    In the case in point, I have provided you with a suggestion on the Perl Monks forum about an hour and a half before you posted here, and, as of now, you still haven't answered my post there. You also received some valuable advice from at least another Perl monk. I do not know if my suggestion solves your problem, but it looks like you did not even try it (perhaps did not even read it). On this forum just as on Perl Monks, many people (like me) are trying to help out others for free. It would be nice to be a bit more responsive toward people that you don't know, but that made some efforts to help you out although they don't know you either.

    Comments on this post

    • Jacques1 agrees
    Last edited by Laurent_R; January 21st, 2014 at 04:48 PM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    MAIL::SENDMAIL - Inserting $variable Into TO or FROM?


    You are correct. My question was posted at PerlMonks and I received a suggestion from Ken which led me to solve my problem.
    I was seeking help anywhere I could get it and sincerely appreciate everyone's assistance.

    Milti

IMN logo majestic logo threadwatch logo seochat tools logo