Perl mail script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl mail script
# 1  
Old 02-12-2015
Perl mail script

Need assistance in programming perl script .

Below script works but Needs slight modification .

This script actually sends attachment as well the image in message. Runs locally but If I run in a directory path , image doesnt come but attachment comes in the message . How can i take the
Code:
<img src="cid:$path/cpu.png"

to work. Your assistance is highly appreciated.

Code:
#!/usrbin/perl

use MIME::Lite;
use Sys::Hostname;

#use strict;

$from = 'a@a.com';
$to = 'b@a.com';
$hostname = Sys::Hostname::hostname();
$Subject = "test mail";
my $path = $ARGV[0];

# Part using which the attachment is sent to an email #
$msg = MIME::Lite->new(
        From     => $from,
        To       => $to,
        Subject  => $Subject,
        Type     => 'multipart/Mixed',
    );
#$msg->attach(
#      Type     => 'Text',
#      Data     => "The attachment contains your file"
#    );

$msg->attach(Type => 'text/html',
             Data => qq{ <body>
                             Here's <i>my</i> image:
                             <img src="cid:test.png">

                             </body> }
                 );

$msg->attach(
    Type     => 'Image/gif',
    Path         => "$path/test.png"
    );

print "Mail Sent\n";
#trap { $msg->send or print "Error: $@\n" };
#$_ and print "Error: $_\n" for $trap->die, $trap->stdout, $trap->stderr;
$msg->send; # send via default

---------- Post updated at 02:08 PM ---------- Previous update was at 01:45 PM ----------

Thanks everythone I found the answer
# 2  
Old 02-12-2015
What was the answer?
# 3  
Old 02-12-2015
Whatever the image that was attached the
Code:
<img src="cid:test.png"

CID --content-id = url-addr-spec

automatically take as IMAGE on the mail message. for more information please check on the internet.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. Shell Programming and Scripting

perl script to check the mail ids in the correct format or not

Hi Folks, I have few mailids in a text file and need to check whether the mailid is in correct format or not. If just to check whether the string is a mailid or not there is a perl module Email::Valid to do the business or we can implement our own logic. But the mail_ids I am having is... (4 Replies)
Discussion started by: giridhar276
4 Replies

3. Shell Programming and Scripting

not able to send the mail through perl script

I have written small piece of code to send mail through perl script.Below is the code.I have executed it as # perl perlmail.pl and the code got executed with no errors. Still have not received any mail. Also I have installed Mail::send module from CPAN directly but no luck. Could any mail... (2 Replies)
Discussion started by: giridhar276
2 Replies

4. Programming

Problem with Mail merge in perl

This could be a simple problem for the perl experts I am trying mail merge in perl The header file is head1 which is as under ... (6 Replies)
Discussion started by: sunnyboy
6 Replies

5. Shell Programming and Scripting

Generate script perl mail log not work

Dear unix forum members, I'm working on a script that will parse a mail machine's logs and print a list of email addresses in this format: authen@domain.com | sender@domain | recipient@domain exam account1@domain1.com | sender2@domain2.com |... (3 Replies)
Discussion started by: puka
3 Replies

6. Shell Programming and Scripting

How to use E-mail functionality in Perl script

Dear all, I have created a perl script with pattern matching, and which loads the data from the Input data file into the Oracle table, and after the load is successful, it deletes the file. Now i want to do some enhancements to the script; 1) E-mail the user with the log file and the... (1 Reply)
Discussion started by: msrahman
1 Replies

7. Shell Programming and Scripting

Using Perl to utilize Mail Command

Does anyone know a way to use the mail command in perl as a one-liner? I am trying to do something like system("mail username@gmail.com -s Tester) but the only catch is to place the period "." after using the mail command in order to complete the command. I do not want to install any other 3rd... (2 Replies)
Discussion started by: twhitmarsh
2 Replies

8. Shell Programming and Scripting

script to read mail on a mail server

Hi All, Is there any way Unix shell script can directly read a mail on a mail server (for eg. abc@xyz.com) and save it as a text file in a unix directory ? Thanks PRKS ---------- Post updated at 08:37 AM ---------- Previous update was at 08:36 AM ---------- I am using ksh (1 Reply)
Discussion started by: PRKS
1 Replies

9. Post Here to Contact Site Administrators and Moderators

e-mail sent to user about PERL

Is there a way to setup an e-mail job (thru my account) to send me e-mail every time a new question or response to PERL is entered into a forum? thanks, djehresmann (1 Reply)
Discussion started by: djehresmann
1 Replies

10. Shell Programming and Scripting

PERL: ping and e-mail

I need a script to open a text file with ip's in it, ping them, split the results into the ip and time from the results and e-mail them ? here what i've done. its porbly wrong and not workin.its for win nt4 use Net::SMTP; # get list of ip's to ping open (PINGFILE, "< c:\\Documents and... (20 Replies)
Discussion started by: perleo
20 Replies
Login or Register to Ask a Question