I'm using MIME::Entity module to send an email. In that i'm facing one issue. If i sent any attachment file, I'm getting attached file content in body as well file also attached in that mail. I have copied some part of code which i'm using to send an email.

## Open sendmail via pipe $fh = new FileHandle(); ## -t = Scan's the input for recipient headers. ## -oi = Set interactive delivery mode. ## -oem = Enable BerkNet processing, and mail back for errors unless ($fh->open("|/usr/lib/sendmail -t -oi -oem")) { ## Failed to open sendmail #error_log("Unable to open pipe for sendmail.", $!, $main::prog,'email_delivery', 'FATAL', 'ERROR'); print "Unable to open pipe for sendmail. $!, $main::prog,'email_ +delivery', 'FATAL', 'ERROR'"; return 0; ## failure ## } ## Build MIME message $message = MIME::Entity->build ( 'Type' => 'multipart/mixed', 'To' => $emailaddress, 'Subject' => $emailsubject, 'X-Mailer' => undef); ## Check if we received an object back unless (defined $message) { #error_log("MIME::Entity->build() failed to + return an object reference.", "", $main::prog, 'email_delivery','FAT +AL', 'ERROR'); print "MIME::Entity->build() failed to retu +rn an object reference., $main::prog, 'email_delivery','FATAL', 'ERR +OR'"; return 0; ## failure ## } ## Attach a message body $message->attach(Data => 'Your data has been a +ttached to this message.'); # Attach the file as an octet-stream $message->attach(Type => 'application/octet-st +ream', Path => $infile, Encoding => 'base64') +; $message->print($fh); $fh->close();

Note :
If I send any file with out extension, then the file is coming only in attachment, the file content will not display in body. Else, I send any file with extension, then only the file content is copying in body and file also coming in attachment.
Can any one please help me to resolve the issue.
Thanks in advance.


In reply to Issue in sending attachment file using MIME::Entity by perlaki

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.