Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: MIME Lite no line feed in Message body

by sudheer157 (Initiate)
on Jun 26, 2011 at 12:10 UTC ( #911450=note: print w/ replies, xml ) Need Help??


in reply to Re: MIME Lite no line feed in Message body
in thread MIME Lite no line feed in Message body

Thanks Corion,
changing it to "text/plain" resolved the issue.

is there any way perl can interpret the format automatically if the file is a plain or html, because my case is the body file may be a plain or html file. so really need a way to identify the format and use plain or html accordingly. Any Ideas?


Comment on Re^2: MIME Lite no line feed in Message body
Re^3: MIME Lite no line feed in Message body
by derby (Abbot) on Jun 26, 2011 at 12:20 UTC
Re^3: MIME Lite no line feed in Message body
by ww (Bishop) on Jun 26, 2011 at 13:12 UTC
    "so really need a way to identify the format and use plain or html accordingly."

    If you're sending it, you should know what the content is. So, no, you don't "really need" some external evaluation of the file type... unless you're being paid to send spam without reviewing the content :-)

    That said, you might also consider a file test construct like:

    unless -T $FH ...(do something) See http://perldoc.perl.org/perlfunc.html

    But - - IMO - - it's "the long way around Robin Hood's barn" to code up file-type-test procedures and translate their output to something you can stick into $mime_msg->attach(Type => '.... unless you have some need to send files whose type is not readily discernable by inspection... or such a volume to send that inspection is impractical.

    PS, just in case: the idiom marked with quotes in the previous para translates (roughly) to "the hard way" or "a poor way."

      Thanks for your reply Derby&WW

      Thing is i am writing a generic script which can accpet n number of attachements(plain/html/pdf/csv -- here i need to find out the attachment type programatically). the first attachement should go as the email body content(can be plain/html) and the rest of the attachemnts as attached to email. Able to attach any number of attachements. but failing to attach the first one inside the body of the email( is also going as external attachment).

      Any cool way to achive this ??

        I don't have access to other perl email modules other than MIME:Lite here is the scenario
        $file='file.html'; $mime_msg->attach(Type => 'text/html', Path => $file, Filename => $fil +e ) or die "Error attaching html: $!\n";

        is working fine and content of file.html is coming as body of the email.


        problem scenarioo

        $file='file.html'; $mime_msg->attach(Type => 'text/html', Path => $file, Filename => $fil +e ) or die "Error attaching html: $!\n"; $file2='attach.csv'; $mime_msg->attach(Type => 'application/csv', Path => $file2, Filename +=> $file2 ) or die "Error attaching html: $!\n";

        in this case both files are coming as attachments, i am expecting the first file file.html to be body of the email and attach.csv as an attachment. Any reason for this

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-10-25 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (148 votes), past polls