LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 03-02-2004, 04:04 PM   #1
patpawlowski
Member
 
Registered: Mar 2003
Location: Centreville, Virginia
Distribution: Mandrak, Red Hat
Posts: 163

Rep: Reputation: 30
Does anyone know how to send a HTML emial.


How do you send an HTML email? I always assumed that if you designed a web page and put it in a plain text email that the client would detect the <html> tag and display it appropriately. Evidently not. I need to know what to enter into a plain text email so that the receiving email client will interpret the markup.

thanks,
 
Old 03-02-2004, 04:25 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Which email client do you use? HTML mail is usually sent as an attachment.
 
Old 03-02-2004, 07:56 PM   #3
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
I believe HTML e-mails generally have a header specifying that it is a Content-Type of HTML. Depending on your e-mail client, there is probably an option somewhere to specify if you want to send HTML or plain text e-mails, and then it will set the header appropriately.
 
Old 03-02-2004, 09:17 PM   #4
patpawlowski
Member
 
Registered: Mar 2003
Location: Centreville, Virginia
Distribution: Mandrak, Red Hat
Posts: 163

Original Poster
Rep: Reputation: 30
I'm not using a client the email will be sent from our web server via a form.
 
Old 03-02-2004, 09:45 PM   #5
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Ok, then what API, object, whatever are you using to send the e-mail? Many of them I have used have a way of specifying that you want to send the mail in an HTML format. Or are you just connecting with a socket to an SMTP server and doing all the protocol work yourself?
 
Old 03-03-2004, 03:44 AM   #6
codedv
Member
 
Registered: Nov 2003
Location: Slough, UK
Distribution: Debian
Posts: 146

Rep: Reputation: 15
The following would be the conversation which takes place with the SMTP server to send a simple HTML e-mail:
Code:
HELO: email-client
250 good
MAIL FROM: test@testaddress.com
250 good
RCPT TO: toemail@test.com
250 good
DATA
354 start mail input
To: Joe Bloggs <joeb@test.com>
From: Test <test@test.com>
Subject: Test HTML E-mail
Content-Type: multipart/mixed; boundary = 1000010000
MIME-Version: 1.0

This is a MIME encoded message.


--1000010000
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: base64


PGh0bWw+CjxoZWFkPgo8L2hlYWQ+Cjxib2R5Pgo8YSBo
cmVmPSJ3d3cubXlsaW5rLmNvbSI+dGVzdCBsaW5rPC9h
Pi4gCjxoMT5UaGlzIGlzIGEgdGVzdCBlLW1haWwgc2Vu
dCBpbiBodG1sIGZvcm1hdDwvaDE+CjwvYm9keT4KPC9od
G1sPg==--
.
250 mail queued for delivery
QUIT
The bits in bold are what the SMTP server says. Its usually good practice to encode content. The base 64 encoded part of the message reads:
Code:
<html>
<head>
</head>
<body>
<a href="www.mylink.com">test link</a>. 
<h1>This is a test e-mail sent in html format</h1>
</body>
</html>
The above dialogue will work if you connect directly to an SMTP server. If you replace the address in the RCPT TO line with your own email address you should reiceve a nice HTML e-mail in your mail box.
 
Old 03-03-2004, 08:17 AM   #7
patpawlowski
Member
 
Registered: Mar 2003
Location: Centreville, Virginia
Distribution: Mandrak, Red Hat
Posts: 163

Original Poster
Rep: Reputation: 30
I was using PHP to send the email. The book I was using didn't cover HTML email but I found what I needed on the PHP website. Basically I needed to add:

"MIME-Version: 1.0\r\n";
"Content-type: text/html; charset=iso-8859-1\r\n";

to the header. Essentially what codedv said.

Thanks everyone.
 
  


Reply



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
Send HTML mail via command line interface xlash Linux - General 2 11-02-2005 01:02 PM
Java Mail fails to send a HTML mail eantoranz Programming 1 11-10-2004 01:47 PM
send my html in outlook icepig General 4 07-15-2004 10:00 AM
How to send an mime/html-email by command line ? fluppi Linux - Networking 0 07-08-2004 09:26 AM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:55 AM.

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
Open Source Consulting | Domain Registration