Sponsored Content
Full Discussion: Perl mail script
Top Forums Shell Programming and Scripting Perl mail script Post 302935075 by ajayram_arya on Thursday 12th of February 2015 03:08:42 PM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Mail::Send(3)						User Contributed Perl Documentation					     Mail::Send(3)

NAME
Mail::Send - Simple electronic mail interface SYNOPSIS
require Mail::Send; $msg = Mail::Send->new; $msg = Mail::Send->new(Subject => 'example', To => 'timbo'); $msg->to('user@host'); $msg->to('user@host', 'user2@example.com'); $msg->subject('example subject'); $msg->cc('user@host'); $msg->bcc('someone@else'); $msg->set($header, @values); $msg->add($header, @values); $msg->delete($header); # Launch mailer and set headers. The filehandle returned # by open() is an instance of the Mail::Mailer class. # Arguments to the open() method are passed to the Mail::Mailer # constructor. $fh = $msg->open; # some default mailer $fh = $msg->open('sendmail'); # explicit print $fh "Body of message"; $fh->close # complete the message and send it or die "couldn't send whole message: $! "; DESCRIPTION
Mail::Send creates e-mail messages without using the Mail::Header knowledge, which means that all escaping and folding must be done by you! Simplicity has its price. When you have time, take a look at Mail::Transport METHODS
Constructors Mail::Send->new(PAIRS) A list of header fields (provided as key-value PAIRS) can be used to initialize the object. Header fields $obj->add(FIELDNAME, VALUES) Add values to the list of defined values for the FIELDNAME. $obj->bcc(VALUES) $obj->cc(VALUES) $obj->delete(FIELDNAME) $obj->set(FIELDNAME, VALUES) VALUES will replace the old values for the FIELDNAME. Returned is the LIST of values after modification. $obj->subject(VALUES) $obj->to(VALUES) Sending $obj->open(OPTIONS) The OPTIONS are used to initiate a mailer object via Mail::Mailer::new(). Then Mail::Mailer::open() is called with the knowledge collected in this Mail::Send object. SEE ALSO
This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/. AUTHORS
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog. LICENSE
Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark Overmeer <perl@overmeer.net>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.16.2 2012-08-29 Mail::Send(3)
All times are GMT -4. The time now is 02:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy