Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Mail not sending

by lakeTrout (Scribe)
on Mar 04, 2005 at 18:10 UTC ( [id://436690]=perlquestion: print w/replies, xml ) Need Help??

lakeTrout has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks,

I have a simple form that sends an email. Everything has been working fine for some time now, but when I added another name to the BCC list, the emails stopped coming. Here is a snippet:
... %mail = ( SMTP => 'localhost', from => 'webform@xyz.com', to => "ABCD <$emailAddress>", bcc => 'myaddress\@xyz.com', subject => "License Form", ); $boundary = "====" . time() . "===="; ...
I changed the above to include another BCC name, like so:
to => "XYZ <$emailAddress>", bcc => 'myaddress\@xyz.com, address1\@xyz.com',
when I do this, the emails are no longer sent. Any ideas what might be causing this? Is this not the correct way to add a name? I have also tried something like this to no avail:
bcc => "BCC list <myaddress\@xyz.com, address1\@XYZ.com>",
Thanks for the help!

Replies are listed 'Best First'.
Re: Mail not sending
by jhourcle (Prior) on Mar 04, 2005 at 20:03 UTC

    Don't escape the @ in a single quoted string. You should either use:

    bcc  => 'myaddress@xyz.com'

    or

    bcc   => "myaddress\@xyz.com"

    For debugging things like this, I'd sugest having the program write out the mail being generated to a file, rather than pushing it to sendmail, and taking a look at it. If you want everything in the 'To' line, use the format:

    to    => "ABCD <$emailaddress>, <myaddress\@xyz.com>"

    I thought e-mail addresses format was explained in RFC822/RFC2822, or RFC821/RFC2821, but I'm not seeing it.

    Update: the address specs were in RFC822 and RFC2822

Re: Mail not sending
by trammell (Priest) on Mar 04, 2005 at 19:14 UTC
    I'm curious as to why you're escaping the "@" in the bcc entries, but not the From: entry. Does the email address need a literal "\"? Is your mailer interpreting the addresses somehow?
Re: Mail not sending
by RazorbladeBidet (Friar) on Mar 04, 2005 at 19:03 UTC
    What program are you sending the mail with?
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs
      I am talking directly to sendmail
      $SENDMAIL_CMD = '|/usr/lib/sendmail -t -oi';
      here is my sendmail sub:
      sub sendmail{ my(%mail)= @_; open(MF, $SENDMAIL_CMD) || print "Sendmail Error! ($!)\n";; print MF<<__MAIL_EOF__; From: $mail{from} To: $mail{to} Bcc: $mail{bcc} Subject: $mail{subject} $mail{body} __MAIL_EOF__ }
        Hi!

        Try escaping the comma separating your Bcc: addresses -- it may be interfering with the construction of the %mail hash..

        Will it work using
        bcc => 'myaddress@xyz.com\, address1@xyz.com'

        I'd guess you're being bitten by an inadvertent newline in your inputs. Have you considered using a module? I've had great luck with MIME::Lite over the years.
Re: Mail not sending
by lakeTrout (Scribe) on Mar 04, 2005 at 20:43 UTC
    Thank you hsinclai and jhourcle. Both of those solutions worked! Thank you all for your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://436690]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-16 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found