You wrote:
PS: I'm not sure if this is possible but can you send an email that will display html in html compatible email readers and text otherwise? (if so how would I encorporate this into my example)
This won't help if you have to use
Net::SMTP, but
MIME::Lite makes it a snap to send email with multiple parts of different mime types:
require MIME::Lite;
$msg= MIME::Lite->new(
From => $from_addr,
To => $to_addr,
Bcc => $bcc_list,
Subject => $subject,
Type => 'multipart/alternative',
);
$msg->attach(
Type => 'text/plain',
Data => $some_plain_text,
);
$msg->attach(
Type => 'text/html',
Data => $some_html,
);
Note that
MIME::Lite can send email via
Net::SMTP using the
send_by_smtp method (from the pod):
send_by_smtp ARGS...
Instance method. Send message via SMTP, using Net::SMTP. The opt
+ional ARGS
are sent into Net::SMTP::new(): usually, these are
MAILHOST, OPTION=>VALUE, ...
Note that the list of recipients is taken from the "To", "Cc" and
+"Bcc"
fields.
Returns true on success, false or exception on error.
Or you can set the delivery method using the class method
send:
# change the delivery method and then call vanilla instance method sen
+d()
MIME::Lite->send(’smtp’, "smtp.myisp.net", Timeout=>60);
# ...
$msg->send();
Or you can set the delivery method by providing different arguments to the instance method
send:
$msg->send(’smtp’, "smtp.myisp.net");
Can you provide any more information as to why you can only use
Net::SMTP ?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.