Sending an Email using MIME protocol


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending an Email using MIME protocol
# 1  
Old 11-19-2013
Sending an Email using MIME protocol

Hi All,

I just need to send an email using MIME protocol from perl script. The data of an email should be a HTML table(contains some datas). I just tried to send a normal text which is working fine whereas if i insert HTML tags i am getting errors. I just tried like below

Code:
$mail_host = "mailhost";
$to = "abc@gmail.com";
$from = "def@gmail.com";
$subject = "Workign of MIME";
$data =
"<html>
<body>
<table>
<tr>
<td> Name: </td>
<td> </td>
</tr>        
<tr>
<td> Age: </td>
<td>  </td>
</tr> 
<tr>
<td> Location: </td>
<td> </td>
</tr> 
</body>
</html>"
$msg = MIME::Lite->new (
From => $from,
To => $to,
Subject => $subject,
);
$msg->attach (
Content-Type: text/html; charset="UTF-8"
Data => $data
);
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;

Thanks in advance!!
# 2  
Old 11-19-2013
Your $data string should have a semicolon.

Code:
$data = '<html>
<body>
<table>
<tr>
<td> Name: </td>
<td> </td>
</tr>        
<tr>
<td> Age: </td>
<td>  </td>
</tr> 
<tr>
<td> Location: </td>
<td> </td>
</tr> 
</body>
</html>';

# 3  
Old 11-20-2013
Hi Rajamadhavan,

My code is below.

Code:
$Data = "<html>
<head>
</head>
<body>
<table border=1  cellspacing=0 cellpadding=0 width=85%>
<tr style="text-align:center bgcolor=brown" font-color:>
<td colspan="2" width="97%"  style="line-height:115%"><b><font size="5" color="white" face="Arial"><span style="font-size:16.0pt;line-height:115%;font-family:Arial;color:white;font-weight:bold"> EMPLOYEEE DATABASE </span></font></b></td>
</tr>
<tr>
<td width="24%" height="30%" bgcolor="green" style="text-align:right"><b> <font size="3" color="black" face="Arial"><b><font> <span style="font-size:11.0pt;line-height:115%;font-family:Arial;color:black;font-weight:bold"> Name:</span> </font></b> </td>
<td><font size="3" color="black" face="calibri"> ABCDE </font></td>
</tr>
<tr>
<td bgcolor="#93FFC4" style="text-align:right"><b><font size="3" color="black" face="Arial"> <span style="font-size:11.0pt;line-height:115%;font-family:Arial;color:black;font-weight:bold">AGE </span></font></b> </td>
<td><font size='3' color='black' face='calibri'> 152 </font></td>
</tr>
</table>
</body>
</html>";

If i execute the script i m just getting erros like "Bareware found where operator expected" in most of the lines.

Last edited by prasanna2166; 11-20-2013 at 12:13 AM..
# 4  
Old 11-20-2013
Your data has several characters without any escape that perl interprets differently. Please use this way


Code:
$Data = <<EOF;
<html>
<head>
</head>
<body>
<table border=1  cellspacing=0 cellpadding=0 width=85%>
<tr style="text-align:center bgcolor=brown" font-color:>
<td colspan="2" width="97%"  style="line-height:115%"><b><font size="5" color="white" face="Arial"><span style="font-size:16.0pt;line-height:115%;font-family:Arial;color:white;font-weight:bold"> EMPLOYEEE DATABASE </span></font></b></td>
</tr>
<tr>
<td width="24%" height="30%" bgcolor="green" style="text-align:right"><b> <font size="3" color="black" face="Arial"><b><font> <span style="font-size:11.0pt;line-height:115%;font-family:Arial;color:black;font-weight:bold"> Name:</span> </font></b> </td>
<td><font size="3" color="black" face="calibri"> ABCDE </font></td>
</tr>
<tr>
<td bgcolor="#93FFC4" style="text-align:right"><b><font size="3" color="black" face="Arial"> <span style="font-size:11.0pt;line-height:115%;font-family:Arial;color:black;font-weight:bold">AGE </span></font></b> </td>
<td><font size='3' color='black' face='calibri'> 152 </font></td>
</tr>
</table>
</body>
</html>
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

MIME type for sending gzip file as attachment in email

Hello, I am trying to send a gzip file on email using below command but the zipped file received on email is corrupt. mailsend -smtp $smtpip -content-type 'application/x-gzip' -mime-type "application/x-gzip" -t $receiver -f $sender -sub "$subject" -M "$MSG" -attach $file file name is ... (1 Reply)
Discussion started by: tushar.modgil
1 Replies

2. Shell Programming and Scripting

uuencode to MIME email attachment converter?

Hello all, we have an IMAP email system here that basically uses email as the transport for a transaction processing system. Users submit their transaction via an email, and our in-house application pulls the emails from the IMAP server and processes the transaction. Our problem is that we have... (0 Replies)
Discussion started by: lupin..the..3rd
0 Replies

3. Shell Programming and Scripting

Sending Attachment using MIME in UNIX

Hi, I am using the below code for sending attachment in UNIX but only blank attachment is coming in email even the content is not coming. Please help!!! export CONTENT="${DIR}/${RUN_DATE}_mailbody.txt" export SUBJECT="Search Result for Pattern - ${1}" export ATTACH=${2} ( echo... (9 Replies)
Discussion started by: rajesshh
9 Replies

4. Shell Programming and Scripting

Sending Attachment using MIME::Lite and Net::SMTP

Hello, I'm a newbie perl scriptor and i'm trying to figure out why i can't send an email using MIME::Lite with Net::SMTP. I keep receiving the following error: SMTP MAIL command failed: 5.7.1 Helo invalid . at attach1.pl line 31 The error keeps coming from the very last line... (2 Replies)
Discussion started by: xmaverick
2 Replies

5. Shell Programming and Scripting

Problem sending excel attachments with MIME::Lite in perl

I am running a perl script that generates an excel doc and then emails it as an attachment. I can generate the excel file fine. I can scp it from the box and open it with no problems. When I send it over email, the file does open properly. The file in email is only 288 B, but on the server it is... (1 Reply)
Discussion started by: Mike_the_Man
1 Replies
Login or Register to Ask a Question