How to use Net::SMTP to mail a document?

Bill Mandel (bmandel@loop.com)
Mon, 16 Sep 1996 05:46:02 -0700


How do you mail yourself a document using Net::SMTP ?


I'm trying the following (Listing 1), but (among other things) I am not
sure how to end each string (\n, \r\n, "", etc... ?) 

Currently it mails everything but Only the "Subject" is parsed properly
the mail system.

Also listing 2 is the mail message received.



Thanks,
Bill Mandel
bmandel@loop.com



Listing #1: (sending routine)



sub SendDocument
{
    local ($to) = shift @_;

    $smtp = Net::SMTP->new('smtp.loop.com');
        
    $smtp->mail("bmandel");
    
    $smtp->to($to);
    
    $smtp->data();

    $smtp->datasend("Subject: AutoSurf\r\n");
    $smtp->datasend("Content-Type: multipart/mixed;
boundary=\"------------5ADEC09B1959CE2F1D69C2F9\n");
    $smtp->datasend("To: $to\r\n");
    $smtp->datasend("\n");

    $smtp->datasend("--------------5ADEC09B1959CE2F1D69C2F9\n");
    $smtp->datasend("Content-Type: text/html; charset=us-ascii;
name=\"results.html\"\n");
    $smtp->datasend("Content-Transfer-Encoding: 7bit\n");
    $smtp->datasend("\n");

    open (HTML,"<results.html");

    while (<HTML>)
    {
	$smtp->datasend($_);
    }
    
    close (HTML);

    $smtp->dataend();
    
    $smtp->quit;    
}



Listing #2: (received mail)