LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-29-2003, 09:07 AM   #1
brokenfeet
LQ Newbie
 
Registered: Jul 2003
Posts: 8

Rep: Reputation: 0
set content-type to 'text/html' in sendmail, using perl script


I think the subject probably explains what I'm trying to do....

System Info: Linux (none) 2.4.20-6um #1 SMP Fri Jun 6 10:15:19 EDT 2003 i686 unknown.

I have a mailing list application that currently manages just fine, but am building v2 of the site and want to be able to include HTML email options for the owner of the list.

Is there a way that I can change the default format of sendmail to "text/html" in the header of the email, or do I have to get my sysadmin to do something?

Any help would be greatly appreciated.

Paul
 
Old 08-01-2003, 02:55 PM   #2
brokenfeet
LQ Newbie
 
Registered: Jul 2003
Posts: 8

Original Poster
Rep: Reputation: 0
somebody must know how to do this??

please?

paul
 
Old 08-03-2003, 03:08 PM   #3
brokenfeet
LQ Newbie
 
Registered: Jul 2003
Posts: 8

Original Poster
Rep: Reputation: 0
the solution....

And the answer is....

Okay, for everyone else who wants to do this using a perl script, I figured out the answer.....

When writing the email header to sendmail, simply include an extra line sending the content type BEFORE sending the double-line carriage that seperates the header from the body. My problem was that I was originally including the "Content-Type: text/html" line AFTER I had already closed the header with a double line break, so sendmail thought it was part of the email body.

So...

open (SM, "|$sendmail $from_email") || print("Sendmail could not be opened") && exit();
print (SM "From: $from_name <$from_email>\n");
print (SM "To: \"$to_name\" <$to_email>\n");
print (SM "Subject: $subject\n");
/* The following two lines were added and allowed the HTML to send inline -- not sure if the "MIME-Version" line is required or not, but it's working now so I won't touch it. */
print (SM "MIME-Version: 1.0\n");
print (SM "Content-Type: text/html\n\n");
/* The following line sets up the HTML for the message so the user doesn't have to include it in the textarea field. */
print (SM "<HTML><BODY>");
print (SM "Hello $to_name!<BR><BR>");
print (SM "$email_content<BR><BR>");
print (SM "To be removed from the mailing list, click the following link.\n");
print (SM "$mailcgisrc?unsubscribe&$to_email\n\n");
/* The following line closes the HTML for finnicky mail programs. */
print (SM "</HTML></BODY>");
close (SM);


And thus, an HTML email is sent to each person on my list.

Paul
 
Old 08-05-2003, 02:12 PM   #4
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
why don't you just do "select SM" and get rid of having to type in SM all the time?
 
  


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
Running a Perl script with SendMail NewByy Programming 2 08-25-2005 09:56 AM
Line breaks in html with perl script BroX Programming 18 01-10-2005 09:07 AM
Cannot not run executable jar file after set content type for download antony_csf Programming 1 12-08-2004 12:22 AM
use CGI vs. content-type: text/html johnensd Red Hat 0 05-09-2004 11:55 PM
Perl Script Reading a txt file and generate html to be published! kofi Linux - Software 1 09-22-2003 05:12 PM

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

All times are GMT -5. The time now is 01:05 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
Open Source Consulting | Domain Registration