If you want to send mail without external module,you'll need more efforts.Net::SMTP is over powerful.If you know more details about email format,it works for you.

To send a mail,Net::SMTP is the only module you need.Open your outlook express(or any other mail clients),drag an email to the desktop,then open the eml file by notepad.

Send the email from your script based on the format of the eml file's content.

The following codes show how to send a Base64 encoding letter with html format.It works on XP and Vista.

The MIME::Base64 is not necessary according to your email client's encoding. If you use basic authorization,AUTHEN::SASL is also unnecessary.

# These codes are written in 2003 package Mnsend; use Net::SMTP; use MIME::Base64; use strict; ### Modify email address and password first ############# ### at line like: $Smtp->auth('vvvvvv@gggg.com','yyyyyyy'); # # SendAlert(HP<hp@163.com>,'Example','<html>hello,world!</html>','a@16 +3.com,b@163.com'); ########################################################## # Encoding head,if your mother language is English # replace "=?GB2312?B?".$name."?=" with $name sub headerconvert{ my $name=shift; $name = encode_base64($name); chomp($name); return $name = "=?GB2312?B?".$name."?="; } sub mailheaderconvert{ my $name=shift; my ($first,$second)=($name=~m/^(.+)<(.+)>/); $first=headerconvert($first); $name="\"$first\"<$second>"; } sub SendAlert { my( $name, $subname, $Message, $List ) = @_; # rewrite message here $name = mailheaderconvert($name); my $alert = headerconvert($subname); # The html body is same as text,it is just a example. # In real world,$htmlmsg may be '<html><b>hello,world</b></html>' # the $testmsg may be 'hello,world!' my $textmsg = encode_base64($Message); my $htmlmsg = encode_base64($Message); foreach my $Recipient ( @$List ) { my $Smtp; my( $Host ) = ( $Recipient =~m/\@(.*)/ ); #if your mail address suffix is not same as your mail server n +ame #uncomment code below #my $Host = "your mail server name"; #print "Sending message to $Recipient...at $Host..."; if( $Smtp = new Net::SMTP( $Host ) ) { # modify the email address and password at your will. $Smtp->auth('vvvvvv@gggg.com','yyyyyyy'); $Smtp->mail($ENV{USER}); #print $Smtp->domain,"\n"; #begin mail $Smtp->mail( "Perl Pager" ); $Smtp->to( $Recipient ); #only for address $Smtp->data(); #$Smtp->datasend( "Date: Tue, 15 Jul 2003 15:32:19 +0800\n +" ); my @body=@{&getbody($name,$Recipient,$alert,$textmsg,$html +msg)}; foreach my $bodyline (@body){ $Smtp->datasend($bodyline); } $Smtp->dataend(); $Smtp->quit(); } else { print "failed\n"; `net send localhost "Mnsend"`; return undef; } print "success\n"; } return 1; } sub getbody { my @body=undef; my ($name,$Recipient,$alert,$textmsg,$htmlmsg)=@_; $body[0]="From: $name\n"; $body[1]="To: $Recipient\n"; $body[2]="Subject: $alert\n"; $body[3]="MIME-Version: 1.0\n"; $body[4]="Content-Type: multipart/alternative;\n"; $body[5]=" boundary=\"----=_NextPart_000_0017_01C34 +AE6.494814A0\"\n"; $body[6]="X-Priority: 3\n"; $body[7]="X-MSMail-Priority: Normal\n"; $body[8]="X-Mailer: Microsoft Outlook Express 5.50.4522.12 +00\n"; $body[9]="X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4 +522.1200\n"; $body[10]="\n"; $body[11]="This is a multi-part message in MIME format.\n" +; $body[12]="\n"; $body[13]="------=_NextPart_000_0017_01C34AE6.494814A0\n"; $body[14]="Content-Type: text/plain;\n"; $body[15]=" charset=\"gb2312\"\n"; $body[16]="Content-Transfer-Encoding: base64\n"; $body[17]="\n"; $body[18]="$textmsg\n"; $body[19]="------=_NextPart_000_0017_01C34AE6.494814A0\n"; $body[20]="Content-Type: text/html;\n"; $body[21]=" charset=\"gb2312\"\n"; $body[22]="Content-Transfer-Encoding: base64\n"; $body[23]="\n"; $body[24]="$htmlmsg\n"; $body[25]="\n"; $body[26]="------=_NextPart_000_0017_01C34AE6.494814A0--\n +"; $body[27]="\n"; return \@body; } 1;
Good luck to you.

In reply to Re: Sending mail from perl script by camenix
in thread Sending mail from perl script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.