CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Sending Attachment using MIME::Lite

 

First page Previous page 1 2 Next page Last page  View All


FishMonger
Veteran / Moderator

Sep 1, 2009, 6:36 AM

Post #26 of 37 (3011 views)
Re: [xmaverick] Sending Attachment using MIME::Lite [In reply to] Can't Post

Try this:


Code
#!/usr/bin/perl 

use strict;
use warnings;

my $from = 'elliot.anico@cellularatsea.com';
my $to = 'eanicom@hotmail.com';
my $cc = 'eanicom@gmail.com';
my $subj = 'Testing';
my $body = "test.txt";


open my $pipe, '|-', '/usr/bin/mailx', '-s',$subj, '-c', $cc, $to, "-f$from",
or die "can't open pipe to mailx: $!\n";

print $pipe `uuencode $body`;

close $pipe;



(This post was edited by FishMonger on Sep 1, 2009, 6:36 AM)


xmaverick
User

Sep 1, 2009, 7:21 AM

Post #27 of 37 (3008 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

Wouldn't i have to specify the file path and attachment on the open my $pipe section of the script?


xmaverick
User

Sep 3, 2009, 7:25 AM

Post #28 of 37 (3003 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

I modified the code like this:

#!/usr/bin/perl -w
use strict;
use warnings;

my $baseDir = '/export/home/omcadmin/bin';
my $attachment = "$baseDir/message.txt";

my $from = 'elliot.anico@cellularatsea.com';
my $to = 'eanicom@hotmail.com';
my $cc = 'eanicom@gmail.com';
my $subj = 'Testing';
my $body = 'TEST';


my $cmd = "uuencode $attachment |mailx, '-s',$subj, '-c', $cc, $to, "-f$from"";
system ("$cmd");



unfortunately i get errors like this:

email.pl: use: not found
email.pl: use: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: syntax error at line 19: `system' unexpected


FishMonger
Veteran / Moderator

Sep 3, 2009, 7:34 AM

Post #29 of 37 (3002 views)
Re: [xmaverick] Sending Attachment using MIME::Lite [In reply to] Can't Post

The error message indicates line 19, but the code you posted only has 16 lines, which tells me that it's not the same code you tested when you got that error.


xmaverick
User

Sep 3, 2009, 7:40 AM

Post #30 of 37 (3000 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

It's the same script. It could just be the spaces. I'm using vi editor in the unix box.


FishMonger
Veteran / Moderator

Sep 3, 2009, 7:48 AM

Post #31 of 37 (2999 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

Wrap your code in the code tags so that the formatting is retained.

You have a problem with the quotes on the $cmd assignment. Why are you using the commas in the command?

Try this:

Code
my $cmd = qq(uuencode $attachment |mailx -s $subj -c $cc $to -f $from);



(This post was edited by FishMonger on Sep 3, 2009, 7:49 AM)


xmaverick
User

Sep 3, 2009, 8:09 AM

Post #32 of 37 (2994 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

Here is how the code looks like now:

#!/usr/bin/perl -w


use strict;
use warnings;

my $baseDir = '/export/home/omcadmin/bin';
my $attachment = "$baseDir/message.txt";

my $from = 'elliot.anico@cellularatsea.com';
my $to = 'eanicom@hotmail.com';
my $cc = 'eanicom@gmail.com';
my $subj = 'Testing';
my $body = 'TEST';


my $cmd = qq(uuencode $attachment |mailx -s $subj -c $cc $to -f $from);
system ("$cmd");


Here is the error now:
email.pl: use: not found
email.pl: use: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: syntax error at line 18: `(' unexpected



Strange!!!


FishMonger
Veteran / Moderator

Sep 3, 2009, 8:21 AM

Post #33 of 37 (2993 views)
Re: [xmaverick] Sending Attachment using MIME::Lite [In reply to] Can't Post

What version of perl are you using i.e., what is the output of this command?


Quote
perl -v



xmaverick
User

Sep 3, 2009, 8:25 AM

Post #34 of 37 (2990 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

I get the following:


This is perl, v5.8.4 built for sun4-solaris-64int
(with 32 registered patches, see perl -V for more detail)

Copyright 1987-2004, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.


KevinR
Veteran


Sep 3, 2009, 9:42 AM

Post #35 of 37 (2986 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

Just a heads-up Fish:

http://www.unix.com/shell-programming-scripting/118486-email-attachment-script.html
-------------------------------------------------


FishMonger
Veteran / Moderator

Sep 3, 2009, 11:15 AM

Post #36 of 37 (2981 views)
Re: [KevinR] Sending Attachment using MIME::Lite [In reply to] Can't Post

Thanks Kevin


xmaverick
User

Sep 4, 2009, 9:18 AM

Post #37 of 37 (2972 views)
Re: [FishMonger] Sending Attachment using MIME::Lite [In reply to] Can't Post

Yeah , i posted my question on another forum for other suggestions. I modified my script even more and now it looks like this and it works.

#!/usr/bin/perl -w


use strict;
use warnings;

my $attachment = 'something.jpg';

my $from = 'xxx@domain.com';
my $to = 'xxx@domain.com';
my $cc = 'xxx@domain.com';
my $subj = 'Testing';
my $body = 'TEST';

my $cmd = "uuencode $attachment $attachment | mailx -r $from -s $subj -c $cc $to";
system ("$cmd);


I finally got the code to send attachments. Now, i'm trying to figure out how to include the body into my statement.

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives