Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-01-2005, 09:28 AM   #1
LQ Newbie
Registered: Jan 2005
Posts: 27

Rep: Reputation: 15
perl emailing html with embedded image

Right now I'm working on a simple email script that will send out a image with it in the message in html format. I can do this with an outlook client , but I haven't been able to reverse engineer it. Basically the image will be attached to the message and shown in the body of the message using HTML.

So far I've been able to attach the Image file to the message as an attachment, but that is it. How do I display it in the message itself?

$filename = "image.png";
$mail{from} = "system\";
$mail{to} = "";
$mail{subject} = "Picture you Requested";

$boundary = "====" . time() . "====";
$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";

$html = encode_qp();

open (F, $filename) or die "Cannot read $filename: $!";
binmode F; undef $/;
$mail{body} = encode_base64(<F>);
close F;

$boundary = '--'.$boundary;
$mail{body} = <<END_OF_BODY;

Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Content-Type: application/octet-stream; name="$filename"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$filename"


sendmail(%mail) or $error_message = $Mail::Sendmail::error;
Old 06-01-2005, 10:44 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,388

Rep: Reputation: 408Reputation: 408Reputation: 408Reputation: 408Reputation: 408
Did you look at the source of those spam emails in html
full of explicit pictures ?

The pictures are not attached in the email, the email contains
only reference to them like any normal html page
(<img src="" ...)
Old 06-01-2005, 10:49 AM   #3
LQ Newbie
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15

I didn't use any of them for example. but I don't want them stored on a http server. I want them to be attached to the message and displayed in the message. I think I almost have it working.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
embedded bash in perl script paul_mat Linux - Software 3 11-21-2005 01:46 PM
How to send email with embedded image shapptastic Solaris / OpenSolaris 1 07-22-2005 11:39 AM
index.html in apache with multimedia embedded htm Linux - Software 3 05-27-2004 10:05 PM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 05:07 AM
HTML code for an image? chadm1967 General 4 09-04-2001 04:41 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration