Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: SMTP client.

by lhoward (Vicar)
on Jun 26, 2000 at 12:33 UTC ( [id://19835]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to SMTP client.

Using <cpan://Net::SMTP> will work fine. It is the nature of internet e-mail that you set the from and to twice if you do raw SMTP; once in the e-mail header and once in the SMTP session. There's a good O'Reilly book Programming Internet Email that goes into all the nasty details of this stuff.

Here's an example from a piece of my code. In this case I uses MIME::Lite to do the actual encoding, but the process should be the same with MIME::Entity. I've removes the error checking in the Net::SMTP communication to make the code smaller and easier to post; you should add the error checking back if you plan to use Net::SMTP. One other note is that MIME::Lite has its own send method that will send the message. So unless you need (or want) to do the SMTP negotiation yourself, MIME::Lite may be an easier solution for you as it can encode, add attachments and send the message.

use Net::SMTP; use MIME::Lite; my $from='foo@testdomain.com'; my $to='bar@testdomain.com' my $msg_html_rich = new MIME::Lite( From => $from, Subject => 'MIME::Lite Test', To => $to, Type => 'multipart/alternative'); attach $msg_html_rich Type =>'text/plain', Data =>'message in plain text'; attach $msg_html_rich Type =>'text/html', Data =>'message in <b>HTML</b> with <i>many</i> markup tags'; my $smtp= Net::SMTP->new('127.0.0.1', Timeout => 180); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend($msg_html_rich->as_string); $smtp->dataend();

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://19835]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.