Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: body content is missing while sending mail with attachment

by roboticus (Canon)
on Jul 28, 2012 at 11:20 UTC ( #984183=note: print w/ replies, xml ) Need Help??


in reply to body content is missing while sending mail with attachment

bheeshmaraja:

Caveat: I don't use mailx or uuencode or ...

I'm expecting that the uuencode command isn't forwarding on the contents of its input stream. So it's as if your open statement is doing something equivalent to:

echo "your message body" >/dev/null uuencode /path/to/document | mailx

If you want to have both of them in the EMail, I'd suggest you do it more like:

sub sendmailto { # Get the text of the attachment: my $attachment = `uuencode /path/to/document.doc`; # Create the mail body: my $message = <<EOMSG; Hullo, all This message blah, blah, blah.... EOMSG # Now send both chunks to mailx open (MAIL, "|mailx -s \"$subject\" -r $from $mailing_list); print MAIL $message; print MAIL $attachment; close MAIL; }

Of course, I'd change the open to use the three argument form, add a little error checking, and neaten it up a little bit. Also this is just typed into a web browser, never tested, so don't be alarmed if it cures world hunger or causes the outbreak of WWIII. Just sayin'.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


Comment on Re: body content is missing while sending mail with attachment
Select or Download Code
Re^2: body content is missing while sending mail with attachment
by bheeshmaraja (Novice) on Jul 30, 2012 at 13:44 UTC
    Thanks roboticus. I have modified my function and now I'm able to get both body message as well as attachment in mail. Function Code:
    sub sendmailto { $mailing_list = $_[0]; $subject = $_[1]; $message = $_[2]; $from = "naga.rajan@gmail.com" $attachment = `uuencode "/home/naga/testing-scripts/Packa +ge_Specification_Document.doc" "Package_Specification_Document.doc" open (MAIL, "|mailx -s "$subject\" -r $from $mailing_list"); print MAIL "Hi, \n"; print MAIL "\n"; print MAIL "This email was sent using an automated email syste +m. Please do not reply, or forward to this email otherwise your messa +ge will not reach your intended recipients. \n"; print MAIL "If you like to contact us pleas write to *UNIX Tea +m. \n"; print MAIL "\n"; print MAIL "Regards, \n"; print MAIL "UNIX Team \n"; print MAIL "\n"; print MAIL "\n"; print MAIL "$message"; print MAIL $attachment; close MAIL; }
    If I paste  print MAIL $attachment; next to mailx  open (MAIL, "|mailx -s "$subject\" -r $from $mailing_list"); then body content is getting missed. If we paste before closing MAIL file handler then we are able to get both body message as well as attachment in mail.

      @ uuencode is not in my meachine .Still i can use same meathod to send email attachment and message body ?

      .

        uuencode is not in my meachine .Still i can use same meathod to send email attachment and message body ?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-07-30 17:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (237 votes), past polls