Is there any easy way to attach files to emails using sendmail? So far the only answer I have seen is through installing the Mail::Sender module from CPAN, but unfortunately we dont have root access to achieve this. Surely there is another way?
uuencode [filename] [attachment name] ¦ sendmail [mail recipient] Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
i am tyro in perl ,please tell me how to send attachments
in perl,java,c.also suggest if i am gonna my own mail server,whichone is better to use.
respond me as soon as possible.
the problem is that normally you open sendmail "| sendmail ..." so that you can print information to it. with uuencode in front of the sendmail pipe, you'll have to do some trickery. try opening up a readable pipe over uuencode ("uuencode ... |" and reading in all the data from that, then printing this data to sendmail later when you're writing the rest of the normal sendmail information to it. i'm not too sure on how uuencode works, though - you may be able to write to the command Mike gave with just a '|' prepended onto it, and uuencode may properly pass this information on to sendmail. i doubt this, however, and would rely on my first suggestion or a permutation thereof...
good luck,
stillflame "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
Wow! Took a couple of attempts, and required backticks in the Perl script, but yes that's it! Seems like it was just down to using backticks in the end.. duh!
Um.. I get a strange subject line though.. and idea how I change it?
Thanks everyone,
Matt.
PS - for anyone else reading this, a quick example of the version that worked...
hmm. rather than doing the second line with the 'cat temp' part, try opening up a sendmail pipe, printing to it the 'To:', 'Subject:', &c. parts, then opening up the temp file you made with uuencode, and printing it into the sendmail pipe. you may have to have a different header on the body of your mail ('multi-part/form' maybe?), but that way you'll have control over the subject line of the mail. also, i think you can include a subject in the initial calling of sendmail, which you could more easily encorporate into your script. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
Stillflames approach sounds the best one Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.