Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Form mail script

by FoncÚ (Scribe)
on Aug 21, 2002 at 14:52 UTC ( #191752=perlquestion: print w/ replies, xml ) Need Help??
FoncÚ has asked for the wisdom of the Perl Monks concerning the following question:

I'm working with a fairly simple form mail script, but I have a few questions to which I cannot find answers. They are as follows:

1. When writing the mail, using commands like print MAIL "From: $fromaddy\n";, that particular one sets the from address, but print MAIL "Subject: $subject\n"; doesn't actually make it the subject of the email. How do I do that?

2. I can't get the user's real name to be the 'from', rather than the email address from which they sent. Not sure just how to do that without error.

3. Is there a particular way to send mail in HTML, or do I just put the tags in there with a print MAIL statement like everything else?

Thanks for the help! FoncÚ

Comment on Form mail script
Select or Download Code
Re: Form mail script
by Tomte (Priest) on Aug 21, 2002 at 15:51 UTC

    1. code, please?
    2. print MAIL "\"Real Name\" <" . $address . ">\n"
    (This is what you meant, isn't it?)
    3. don't :-)


    regards,
    tomte

    Update: typo fixed
Re: Form mail script
by neilwatson (Curate) on Aug 21, 2002 at 15:54 UTC
    Mail::Sender is my friend; snippet:

    sub mailout{ $sender = new Mail::Sender; $sender->Open({ smtp => 'mail', from => "$from", fake_from => "$from", to => "nobody\@mydomain.com", bcc => "$to", encoding => "quoted-printable", subject => "$subject", ctype => "$htype", }) || die "Sender error: $sender, $Mail::Sender::Error!\n"; # body of email $sender->SendEnc(@body) || die "Sender error: $sender, $Mail::Send +er::Error!\n"; # send email $sender->Close || die "Sender error: $sender, $Mail::Sender::Error +!\n"; }

    Neil Watson
    watson-wilson.ca

Re: Form mail script
by screamingeagle (Curate) on Aug 21, 2002 at 15:58 UTC
    try this if you're using Net::SMTP :
    $mail->data(); $mail->datasend("To: you@you.com"); $mail->datasend("From: me@me.com\n"); $mail->datasend("Subject: Subject Text\n"); $mail->datasend("\n"); $mail->datasend("Email content\n\n"); $mail->dataend();
    for sending HTML , set the Content-type of the mail object to "text/html" hth
Re: Form mail script
by LTjake (Prior) on Aug 21, 2002 at 16:50 UTC
    Everyone seems to have their preference for a mail module. I use Mail::Sendmail. It's platform independent, yehaw.

    Sample code (previously posted here, and here):
    use Mail::Sendmail; # Create the message hash my %mail = ( To => 'You <your@address.com>', # To address.. From => 'Me <my@address.com>', # From address.. Message => 'Hello, world!', # The message body.. Smtp => 'your.mail.server' # erase this if you want to use "loc +alhost" (default) ); # Send the message unless (sendmail(%mail)) { # Error! } # All is well.
    Update:
    Whoops, i forgot to add that, the Mail::Sendmail FAQ talks about sending HTML email.
Re: Form mail script
by bart (Canon) on Aug 21, 2002 at 17:05 UTC
    Is there a particular way to send mail in HTML

    Hmm... look at MIME::Lite::HTML, which would solve most of the problems you seem to be having. (ESP mode on, really.)

OT: E is for EVIL-mail (HTML)
by BorgCopyeditor (Friar) on Aug 21, 2002 at 18:44 UTC

    In case you do figure out how to send HTML e-mail, you should know that many people think it's EVIL:

    7 reasons why HTML e-mail is EVIL!!!: link

    How HTML Email Invades Your Privacy: link

    Why Developers Don't Want HTML Email: link

    Security Issues in HTML-based Email: link

    BCE
    --Your punctuation skills are insufficient!

Re: Form mail script
by FoncÚ (Scribe) on Aug 22, 2002 at 03:50 UTC
    The code is on my scratchpad.

    I'll keep those things in mind about HTML email. Tomte, I really did mean what I typed; check out the code. However...that doesn't work right, otherwise it would display normally.

    I'll check out the modules, but I've had a LOT of trouble, having such limited access to my server. I'll just have to see how that goes.

    FoncÚ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-10-26 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (151 votes), past polls