People in cc are not receiving the mail using MIME::Lite api - perl

Please find below my code snippet that send a mail to person and his friend in cc.
In the cc list I also have a DL.
use MIME::Lite;
$to = 'ABC#DOMAIN1.com';
$from = 'MAILER#DOMAIN2.com';
$subject = 'How are you doing';
$message = 'This is test email sent by Perl Script';
my #cc=('XYZ#DOMAIN2.com','DL#DOMAIN2.com');
$msg = MIME::Lite->new(
From => $from,
To => $to,
Cc =>\#cc,
Subject => $subject,
Data => $message
);
$msg->send('smtp','smtpserver', Timeout => 60 );
print "Email Sent Successfully\n";
The problem is the person and DL is cc are not receiving the mails.
Is there any log in the api MIME::Lite where I can check what is the error(if any)Or what do you think the problem can be?

Perhaps you want to take a closer look at the documentation for MIME::Lite. Here's the first example from the synopsis.
use MIME::Lite;
### Create a new single-part message, to send a GIF file:
$msg = MIME::Lite->new(
From => 'me#myhost.com',
To => 'you#yourhost.com',
Cc => 'some#other.com, some#more.com',
Subject => 'Helloooooo, nurse!',
Type => 'image/gif',
Encoding => 'base64',
Path => 'hellonurse.gif'
);
$msg->send; # send via default
The Cc parameter here is sent as a text string containing comma-separated email addresses. You are passing in a reference to an array of email addresses.

Related

Why is attachment file on email blank?

My script sends email to a user with an attachment file.
The file name is hello.txt.
It contains "HELLO WORLD!! :D".
When I send the email, the file hello.txt is attached with the email.
But, when I open the file, hello.txt is blank and empty.
It should contain "HELLO WORLD!! :D"
The CODE
#!/usr/bin/perl
use MIME::Lite;
$to = 'abc#gmail.com';
$from = 'abc#gmail.com';
$subject = 'Test Email';
$message = 'This is test email sent by Perl Script';
$msg = MIME::Lite->new(
From => $from,
To => $to,
Cc => $cc,
Subject => $subject,
Type => 'multipart/mixed' #I SUSPECT, THE PROBLEM AT HERE
);
# Add your text message.
$msg->attach(
Type => 'text',
Data => $message
);
# Specify your file as attachement.
$msg->attach(Type => 'application/text', #I SUSPECT, THE PROBLEM AT HERE
Path => 'C:\Users\Desktop',
Filename => 'hello.txt',
Disposition => 'attachment'
);
$msg->send;
print "Email Sent Successfully\n";
Should I change Type or application/text?
Path => 'C:\Users\Desktop',
Path should be the path name of the file on your system. What you gave is only the directory name, where the file is located. Trying to read this will result in empty data - and thus empty content for the attached file. Instead you need to use
Path => 'C:\Users\Desktop\hello.txt',

MIME::Lite - Mail to multiple recipients [duplicate]

Please find below my code snippet that send a mail to person and his friend in cc.
In the cc list I also have a DL.
use MIME::Lite;
$to = 'ABC#DOMAIN1.com';
$from = 'MAILER#DOMAIN2.com';
$subject = 'How are you doing';
$message = 'This is test email sent by Perl Script';
my #cc=('XYZ#DOMAIN2.com','DL#DOMAIN2.com');
$msg = MIME::Lite->new(
From => $from,
To => $to,
Cc =>\#cc,
Subject => $subject,
Data => $message
);
$msg->send('smtp','smtpserver', Timeout => 60 );
print "Email Sent Successfully\n";
The problem is the person and DL is cc are not receiving the mails.
Is there any log in the api MIME::Lite where I can check what is the error(if any)Or what do you think the problem can be?
Perhaps you want to take a closer look at the documentation for MIME::Lite. Here's the first example from the synopsis.
use MIME::Lite;
### Create a new single-part message, to send a GIF file:
$msg = MIME::Lite->new(
From => 'me#myhost.com',
To => 'you#yourhost.com',
Cc => 'some#other.com, some#more.com',
Subject => 'Helloooooo, nurse!',
Type => 'image/gif',
Encoding => 'base64',
Path => 'hellonurse.gif'
);
$msg->send; # send via default
The Cc parameter here is sent as a text string containing comma-separated email addresses. You are passing in a reference to an array of email addresses.

Perl Net::SMTP Email Size issue while using html format

I am sending an email via SMTP in perl . The email contains some tables,links and lists.
I am using html format data.
$smtp->data();
$smtp->datasend("MIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n<H1>");
$smtp->datasend("$message");
...
$smtp->dataend();
$smtp->quit;
Sometimes the email size is too large around 1mb. Is there any way I can reduce the size of email without reducing the amount of data.I do not want the message as an attachment. I use outlook to open the mails.
You should use Mail::Sender for sending attachments through email
#!/usr/bin/perl
use Mail::Sender
$to = 'email1#example1.com,email2#example2.com';
$sender =new Mail::Sender {
smtp => 'smtp.mailserver.com',
from => 'script#somedomain.com,
});
$subject = 'This is a Test Email';
$sender->OpenMultipart({
to => "$to",
subject => "$subject",
});
$sender->Body;
$sender->SendLineEnc("Test line 1");
$sender->SendLineEnc("Test line 2");
$sender->Attach({
description => 'Test file',
ctype => 'application/x-zip-encoded',
encoding => 'Base64',
disposition => 'attachment;
filename="File.zip"; type="ZIP archive"',
file => "$file",
});
$sender->Close();
exit();
or using MIME::Lite
use MIME::Lite;
$msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
) or die "$!\n";
### Add the ZIP file
$msg->attach (
Type => 'application/zip',
Path => $my_file_zip,
Filename => $your_file_zip,
Disposition => 'attachment'
) or die "Error adding $file_zip: $!\n";
### Send the Message
$msg->send('smtp', $mail_host, Timeout=>60);

MIME::Lite and the Message-ID

When using MIME::Lite is there a way to get the Message-ID assigned by the MTA when the message is accepted? Here's my code snippet.
$msg = MIME::Lite->new(
From => $from_address,
To => $recipient,
Bcc => $recipient,
Subject => $subject,
Type => 'text/html',
Data => $text);
$status = $msg->send();
I've tried setting Debug=>1 in the $msg->send command but $status does not contain the Message-ID nor does the debug output have it.
Thanks,
Rick
No. If you want to know the message ID, you can try setting one yourself, and then checking if your MTA uses it, or overwrites it.

Email does not send with perl MIME::Lite using smtp

I am trying to send an email using MIME::Lite but the email will not send and I am not getting any errors.
Code:
my $subject = $Config->{email}->{subject};
my $from_email = $Config->{email}->{from_email};
my $message = $Config->{email}->{message};
my $smtp_server = $Config->{email}->{smtp_server};
my $msg = MIME::Lite->new
(
Subject => $subject,
From => $from_email,
To => $email,
Type => 'text/html',
Data => $message
);
$msg->send('smtp' ,$smtp_server );
Not much to go on there ...
Maybe try debugging?
$msg->send( 'smtp', $smtp_server, Debug=>1 );
And check all the values in $Config->{email} are as you would expect.