Hello,
I'm a newbie to perl and i'd like some assistance trying to figure out how to send an attachment using MIME::Lite. I have searched the net far and wide and have used and modify different examples of attachment scripts. Unfortunately, i have had no luck trying to execute my script.
Every time i attempt to execute the script i receive the following response:
Global symbol "$msg" requires explicit package name at attach1.pl line 22.
Global symbol "$msg" requires explicit package name at attach1.pl line 30.
Global symbol "$msg" requires explicit package name at attach1.pl line 36.
Global symbol "$file_gif" requires explicit package name at attach1.pl line 41.
Global symbol "$msg" requires explicit package name at attach1.pl line 43.
Below is the code:
#!/usr/bin/perl -w
use strict;
use warnings;
use MIME::Lite;
### Adjust sender, recipient and your SMTP mailhost
my $from_address = 'elliot.anico@c ellularatsea.co m';
my $to_address = 'elliot.anico@c ellularatsea.co m';
### Adjust subject and body message
my $subject = 'A message with 2 parts ...';
my $message_body = "Here's the attachment file(s) you wanted";
### Adjust the filenames
my $my_file_pdf = '/export/home/omcadmin/bin/test.pdf';
my $your_file_pdf = 'test.pdf';
### Create the multipart container
$msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
### Add the text message part
$msg->attach (
Type => 'TEXT',
Data => $message_body
) or die "Error adding the text message part: $!\n";
### Add the PDF file
$msg->attach (
Type => 'pdf/pdf',
Path => $my_file_pdf,
Filename => $your_file_pdf,
Disposition => 'attachment'
) or die "Error adding $file_gif: $!\n";
$msg->send;
I know this is probably something stupid. Can someone assist me with this?
5 7831
When you are using strict pragma, all the local variables in the script need to be declared with my.
Change the line:
to: -
my $msg = MIME::Lite->new (
-
-
As for $file_gif, the variable is not defined anywhere in the script.
numberwhun 3,509
Recognized Expert Moderator Specialist
These are all errors associated with using strict and warnings and need to be worked out to get to any real errors.
Regards,
Jeff
KevinADC 4,059
Recognized Expert Specialist
Already replied to and resolved on another forum.
I see. well, i managed to modify my script but i'm having problems attempting to send the email via Net::SMTP. I keep receiving the following error when i execute the script:
SMTP MAIL command failed:
5.7.1 Helo invalid .
at attach1.pl line 30
This is the very last line in the script below which is
$msg -> send;
Below is my modified script:
#!/usr/bin/perl -w
use warnings;
use MIME::Lite;
use Net::SMTP;
my $msg = MIME::Lite->new(
From => 'elliot.anico@c ellularatsea.co m',
To => 'elliot.anico@c ellularatsea.co m',
cc => 'wms.nmc@cellul aratsea.com',
Subject => 'Multiple attachments',
Type => 'multipart/mixed');
$msg->attach( Type =>'image/jpg',
Path =>'/export/home/omcadmin/bin/Sunset.jpg',
Filename =>'Sunset.jpg') ;
$msg->attach( Type =>'image/jpg',
Path =>'/export/home/omcadmin/bin/Winter.jpg',
Filename =>'Winter.jpg') ;
$msg->attach( Type =>'TEXT',
Data =>'This is a test for outside usage');
$SMTP_SERVER = 'wmsexg01.corp. cellularatsea.c om';
MIME::Lite->send('smtp', 'SMTP_SERVER');
$msg -> send;
What could i be doing wrong?
KevinADC 4,059
Recognized Expert Specialist Sign in to post your reply or Sign up for a free account.
Similar topics |
by: John B. Kim |
last post by:
I am working on the code below:
******************************************************
use strict;
use MIME::Lite;
use Net::SMTP;
my $from = 'steve@earthlink.net';
my @addweek1 = qw(michael@earthlink.net
jennifer@aol.com
);
my $Fnameweek1 = 'JNIssue11.pdf';
|
by: Deen |
last post by:
Hi!
I'm desperately seeking for a Perl script to send a message
with attached documents.
Thanks for help.
|
by: Zev Steinhardt |
last post by:
I'm trying to use Mime::Lite to send out multipart messages. So far,
it all seems to work well except for one small part.
I want to display a "real name" along with the email address when I
send out the emails. Unfortuantely, whenever I do so, it gets bounced
by the program as an invalid email address.
For example, this works:
$msg = MIME::Lite->new(
|
by: ramyaamar |
last post by:
Hii friends
I m new to perl...Just started learning....I want to know how to send an simple email in perl...
I have activex perl and downloaded MIME::LITE and Mail:Mailer modules....
Can anyone tell me how to write the coding!!
Thanks in Advance!!!
|
by: ssankar |
last post by:
hi all -
I have been tasked to send customized emails to a set of users based on a certain condition in my company. ( This is NOT SPAM )
I have used MIME::Lite successfully to send html templates as emails. the users in my company are Outlook users. But for some reason my emails sometimes reach the Junk E-Mail folder( I am sending using my own company issued email address )
Here's the code I currently use:
#!/usr/bin/perl -w
use...
| |
by: idorjee |
last post by:
Hi,
Can anyone please tell why can't send an email with the following script. I'm using mac os x (tiger)'s terminal application. Do I need to change any configuration files?
Thanks a lot in advance.
#!/usr/bin/perl -w
use strict;
use MIME::Lite;
|
by: munisams |
last post by:
Can anyone tell me Is there any python module available which functionally equivalent to Perl's MIME::Lite??
I am searching for a python MIME module which has following features:
1. Able to send multi-attached docs.
2. Able to set priority to mail.
3. Able to send inline images.
Please suggest some python modules which satisfies above requirements.
Thanks,
Srini
|
by: jcor |
last post by:
Hi, I'm trying to create a script that send a file in attachment of a mail:
my code is something like this:
#set up email
my $to = "xxx\@xxxxxx.com";
my $from = "xxx\@xxxxx.com.br";
my $subject = "ficheiro audio ";
my $message = "ficheiro audio ";
my $path = "/home/user/Desktop/outputs/20080101_titulo-teste.mp3";
|
by: wpflum |
last post by:
I'm using Net::POP3, Email:Simple and Email::Mime to pull emails off of a server and parse them for information to see if they are the result of 'bounced' emails from our system. I then send an email internally notifying the original sender that their automated email failed. I've got it working but I'd like to also forward the complete email as an attachment to a specific system address so I can keep a copy in case someone complains that the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |