Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display of image in sending the mail using perl

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hai Guys!


I tried to embed html file in the mail using

print MAIL "Content-type: text/html \n\n";

Here when i tried to import a image its not coming up iam using outlook to view my mail.Not the browser.

:)

 
open(MAIL,"|$mailprog -t");
$from='From@from.com';
$mailarray=$mailid.'@from.com';
$|=1;
print MAIL "To: $mailarray \n";
print MAIL "From:$from \n";
#print MAIL "Subject: Test \n\n";
print MAIL "Content-Type: text/html \n\n";
print MAIL &quot;<html>\n&quot;;
print MAIL &quot;<head>\n&quot;;
print MAIL &quot;</head>\n&quot;;
print MAIL &quot;<body>\n&quot;;
print MAIL &quot;<img src=conbottom.gif>&quot;;
print MAIL &quot;<table border=\&quot;0\&quot; width=\&quot;101\%\&quot; height=\&quot;68\&quot; bgcolor=\&quot;#0000CC\&quot;>&quot;;
print MAIL &quot;<tr>&quot;;
print MAIL &quot;<td width=\&quot;100\%\&quot; height=\&quot;62\&quot;><font face=\&quot;Verdana\&quot; size=\&quot;4\&quot; color=\&quot;\#FFFFFF\&quot;><b>Test</b></font></td>&quot;;
print MAIL &quot;</tr></table>&quot;;
print MAIL &quot;<p>&amp;nbsp\;</p><p>&amp;nbsp\;</p><p>&amp;nbsp\;</p>&quot;;
print MAIL &quot;<p align=\&quot;center\&quot;><b><font face=\&quot;Verdana\&quot; size=\&quot;3\&quot;>&quot;;
print MAIL &quot;<p align=\&quot;center\&quot;><b><font face=\&quot;Verdana\&quot; size=\&quot;3\&quot;>$mail</font></b></p>&quot;;
print MAIL &quot;<br>&quot;;
print MAIL &quot;<p align=\&quot;center\&quot;><b><font face=\&quot;Verdana\&quot; size=\&quot;2\&quot;>Information: </font></b></p>&quot;;
print MAIL &quot;<br>&quot;;
print MAIL &quot;<p align=\&quot;center\&quot;><b><font face=\&quot;Verdana\&quot; size=\&quot;1\&quot;>Name:$name CategoryI: $text,Category II: $com,Category III: $subtext</font></b></p>&quot;;
print MAIL &quot;<p align=\&quot;center\&quot;><b><font face=\&quot;Verdana\&quot; size=\&quot;2\&quot;><a href=\&quot; border=\&quot;0\&quot; src=\&quot; width=\&quot;182\&quot; height=\&quot;71\&quot;></a></font></b></p>&quot;;
print MAIL &quot;<br>&quot;;
print MAIL &quot;</body>&quot;;
print MAIL &quot;</html>&quot;;
$|=1;
close (MAIL);
 
Here is the code which i wrote

open(MAIL,&quot;|$mailprog -t&quot;);
$from='From@from.com';
$mailarray=$mailid.'@from.com';
print MAIL &quot;To: $mailarray \n&quot;;
print MAIL &quot;From:$from \n&quot;;
#print MAIL &quot;Subject: Test \n\n&quot;;
print MAIL &quot;Content-Type: text/html \n\n&quot;;
print MAIL &quot;<html>\n&quot;;
print MAIL &quot;<head>\n&quot;;
print MAIL &quot;</head>\n&quot;;
print MAIL &quot;<body>\n&quot;;
print MAIL &quot;<img src=conbottom.gif>&quot;;
print MAIL &quot;</body>&quot;;
print MAIL &quot;</html>&quot;;
$|=1;
close (MAIL);

Iam not able to display the subject in the mail what i need to put and also is there any other content type i need to use for displaying the image.


 
I'm not sure why yours does not work, but, this does. Change the red to something valid and the <IMG SRC to something valid. Maybe you can use this as a starting point and develop from there.


#!/usr/local/bin/perl
$mailprog = [red]'/usr/lib/sendmail'[/red];
$hdr = 'Mail a gif';
$recipient = 'some.sap@nowhere.com';
$command = &quot;$mailprog -f $hdr $recipient&quot;;

open (MAIL, &quot;|$command&quot;) || die &quot;Can't open $mailprog!\n&quot;;
print MAIL &quot;From: Mr. Saps Boss\n&quot;;
print MAIL &quot;Reply-To: \n&quot;;
print MAIL &quot;Subject: Mail a gif in some embedded HTML\n&quot;;
print MAIL &quot;Content-Type: text/html charset=iso-8859-1\n&quot;;
print MAIL &quot;Precedence: bulk\n\n&quot;;
print MAIL &quot;<html><body><IMG SRC=\&quot;[red][/red]\&quot;>
<h1>testing html</h1></body></html>&quot;;
# Send mail to Recipient
close MAIL;
print &quot;complete\n&quot;;
exit;

'hope this helps.....


keep the rudder amid ship and beware the odd typo
 
In your #commented subject line, there are two newlines. A blank line indicates the beginning of the body, so if you uncommented that, then your content-type would end up in the body and not the header as you would want. So, if you uncomment that line, then remove the second newline (\n).

BTW, if you

print MAIL qq~delimiting &quot;the&quot; strings &quot;with&quot; qq then you wouldn't have to \&quot;escape\&quot; any quotes~;
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Thanks tom And goboating it works fine ,

But my problem is iam using mail client(outlook) to see
the emails ,Its coming up without the images ,When copy the html (by right clicking) and view as html in the webserver it works fine,

If any one had this error ,Thanks buddys you people rock

Thendal
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top