Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Issue in sending attachment file using MIME::Entity

by perlaki (Initiate)
on Jul 13, 2011 at 07:26 UTC ( #914069=perlquestion: print w/ replies, xml ) Need Help??
perlaki has asked for the wisdom of the Perl Monks concerning the following question:

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.

Comment on Issue in sending attachment file using MIME::Entity
Download Code
Re: Issue in sending attachment file using MIME::Entity
by stonecolddevin (Vicar) on Jul 13, 2011 at 14:58 UTC

    Why aren't you using Email::Sender::Simple with Email::MIME::Kit or some such?

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

      my requirement is to use MIME::Entity to send an email

        That doesn't really answer the question, and I'm not willing to help persevere code that pipes output to sendmail.

        Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://914069]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-07-28 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (196 votes), past polls