OK I use the Sendmail module quite a lot and normally have no issues with it, but this time I'm trying to read in the "To" entries from an external file and use them from a variable but it's giving me issues. Sendmail normally expects to see something like this:

%newmsg = ( From => 'whoever@wherever.net', To => 'Joe User <joe.user@wherever.net>', Subject => $subject, Message => "A message to all my fans... Love, Stitch Jones" );

If I put the people for the "To" header into the external file in this format:

Joe User <joe.user@wherever.net>

and read that into a variable $recipients, and then try to mail, Sendmail fails using this syntax:

To => $recipients,

So I've done something like this (to get the single quotes Sendmail apparently needs):

To => "\'.$recipients.\'",

The above WILL send the mail but when the mail arrives the "To:" header in the mail is empty so you can't see (or "reply to all") to the email and get the original receivers as well as the person/email it was sent "From". Seems like it should not work since it is syntactically odd (seems this would be more correct):

To => "\'" . $recipients . "\'",

Running the above nets a "connection failed" to the SMTP server.

Any help here, fellow Monks on getting Sendmail to accept the "To" item from a variable (I've stuck the single apostrophes into the string too with bad results) and still show the To: header properly when the email arrives?


In reply to Sendmail module question by AlphalphaMale

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.