LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-01-2005, 10:28 AM   #1
davesbedroom
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?

Code:
$filename = "image.png";
$mail{from} = "system\@domain.com";
$mail{to} = "lucky@domain.com";
$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;
$boundary

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


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

$mail{body}
$boundary--
END_OF_BODY

sendmail(%mail) or $error_message = $Mail::Sendmail::error;
 
Old 06-01-2005, 11:44 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
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="http://yourhost.com" ...)
 
Old 06-01-2005, 11:49 AM   #3
davesbedroom
LQ Newbie
 
Registered: Jan 2005
Posts: 27

Original Poster
Rep: Reputation: 15
:lol:

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.
 
  


Reply


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 02:46 PM
How to send email with embedded image shapptastic Solaris / OpenSolaris 1 07-22-2005 12:39 PM
index.html in apache with multimedia embedded htm Linux - Software 3 05-27-2004 11:05 PM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 06:07 AM
HTML code for an image? chadm1967 General 4 09-04-2001 05:41 PM


All times are GMT -5. The time now is 11:51 PM.

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