See Re: How do I send an email with Perl (including an attachment)? or do something as simple as this: (beware there are pitfalls in this method, but it works)
#!/usr/bin/perl use strict; use warnings; use MIME::Base64; my $SENDFILE = 'z.jpg'; my $FROMUSER = 'zentara'; my $FROMEMAIL = 'zentara@zentara.zentara.net'; my $TOUSER = 'zentara'; my $TOEMAIL = 'zentara@zentara.zentara.net'; open(F_MAIL,"|/usr/sbin/sendmail -t"); my $boundary = "----------90125"; print F_MAIL <<END_OF_MAIL; Precedence: list From: $FROMUSER <$FROMEMAIL> To: $TOUSER <$TOEMAIL> MIME-Version: 1.0 Subject: File attachment test Content-Type: multipart/mixed; boundary=\"$boundary\" This is a multi-part message in MIME format. --$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Here is the body of the message. A file attachment is also provided b +elow. --$boundary Content-Type: application/octet-stream; name=\"$SENDFILE\" Content-Transfer-Encoding: Base64 Content-Disposition: attachment; filename=\"$SENDFILE\" END_OF_MAIL #open(F_SEND,$SENDFILE) || &Error("Cannot open sendfile for MIME encod +ing"); open(F_SEND,$SENDFILE) || die ("Cannot open sendfile for MIME encoding +"); while (read(F_SEND,my $buf, 60 * 57 ) ) { print F_MAIL encode_base64($buf); } close(F_SEND); print F_MAIL <<END_OF_MAIL; --$boundary-- END_OF_MAIL close(F_MAIL);

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

In reply to Re: Sending E-mail attachment wihout using external module by zentara
in thread Sending E-mail attachment wihout using external module by DreamT

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.