News
: July 14, 2008 - New Contest! -
Submit Your WordPress Theme Designs, Win BIG!
September 1, 2008 -
Submit Your Web Site for the Sept 2008 Site of the Month!
Home
Help
Search
Calendar
Login
Register
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
September 08, 2008, 12:10:48 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Web Hosting Forum | Lunarpages
>
Lunarpages Web Hosting - Advanced Assistance
>
Lunarpages - Web Hosting, Email & PC Security
>
Email header "Content"
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Email header "Content" (Read 498 times)
NevadaSam
The Queen of Cut & Paste
Galactic Royalty
Offline
Posts: 213
Email header "Content"
«
on:
December 10, 2007, 07:17:56 PM »
Sometimes people are receiving emails with a blank text area.
Please show me the proper way to to write the bold part of this line of code.
$headers .=
"Content-Type: text/html; charset=iso-8859-1\r\n";
Sam
;
Logged
Today I ask questions... tomorrow I will have answers.
MrPhil
Quantum Encyclopedia Writer
Offline
Posts: 3266
Re: Email header "Content"
«
Reply #1 on:
December 11, 2007, 10:22:10 AM »
If you're writing your own HTML email for the PHP mail() function:
$to = "recipient's address";
$from_email = "sender's address";
$subject = "your subject line";
$header_sep = "\r\n"; // may have to be \n on some systems
// if you embed user-entered text, change CRs to \n's with str_replace()
$headers = "MIME-Version: 1.0" . $header_sep ;
$headers .= "Content-Type: text/html; charset=iso-8859-1" . $header_sep;
$body = "<html>\n<head>\n<title>Title For Recipient To See</title>\n";
$body .= "</head>\n<body>\n";
$body .= "<p>Here's an email from you</p>\n";
...
$body .= "</body>\n</html>\n";
if ($from_email != "") {
$headers = "From: $from_email" . $header_sep . $headers;
// I think you can put a "Reply-To: ", "Cc: ", etc. in here, too
}
$headers .= $header_sep; // ensure that nothing in the mail body
// can add bogus headers
// make sure resulting body doesn't exceed 70 characters per line
$body = wordwrap($body,70);
if (!mail($to, $subject, $body, $headers)) {
print "<p><font color=\"red\">Unable to send mail! Please try again later.</font></p>\n";
}
I offer no guarantee that there isn't some way to subvert this with "injection attacks" and generate spam. Usually it's safer to use a well-tested canned mail function, but sometimes you just need your own features.
Non-HTML (plain text) emails are a bit different. I'm not sure how to combine the two (HTML as the primary, plain text as the backup in case the email client can't handle HTML) into one email, but I've heard it can be done.
Logged
Visit My Site
E-mail Me
NevadaSam
The Queen of Cut & Paste
Galactic Royalty
Offline
Posts: 213
Email header "Content"
«
Reply #2 on:
December 14, 2007, 04:53:43 PM »
I believe I have most of it straighten out now. I originally had some extra quotes in the content header. There are still some people telling me that they are getting blank text still. Three of them are have a daltonstate.ga.edu email address so I thinking they may be blocked thought most IT guys will block the whole email. Dalton State College is only 20 miles up the road so I might get may sister to drive me up there next week and talk to the IT guys.
I use
$message = "<html><body>".nl2br($message)."</body></html>";
to wrap my text in html.
Logged
Today I ask questions... tomorrow I will have answers.
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Lunarpages Web Hosting - Information & Opportunities
-----------------------------
=> Lunarpages Web Hosting - Announcements
=> Lunarpages Web Hosting - Hosting Plans & Site Information
=> Job Opportunities at Lunarpages Web Hosting
=> Lunarpages Web Hosting - Network Information
=> Lunarpages Web Hosting - Server Information
-----------------------------
Lunarpages Web Hosting - Before Signing Up
-----------------------------
=> Lunarpages Web Hosting Plans - Pre-Sales Questions
-----------------------------
Lunarpages Web Hosting - Online Help Desk
-----------------------------
=> Lunarpages - Webhosting Help
=> Lunarpages - Beginner Assistance
=> Lunarpages - How to's
=> E-mail with your Lunarpages Hosting Plan
=> Lunarpages - CPanel Help
=> Lunarpages - Ecommerce Hosting
=> Lunarpages - FrontPage
=> Lunarpages - DreamWeaver
=> Lunarpages - Message Boards-Forums-Fantastico Scripts
===> Lunarpages - Joomla / Mambo
-----------------------------
Lunarpages Web Hosting - Advanced Assistance
-----------------------------
=> Web Management
=> Lunarpages - Webdesign and HTML
=> Lunarpages - Search Engine Optimization
=> Lunarpages - Animation & Flash
=> Lunarpages - Graphics
=> Lunarpages - Web Hosting, Email & PC Security
=> Lunarpages - Dedicated Web Hosting
=> Lunarpages - Reseller Web Hosting
=> Lunarpages - VPS Hosting
=> Lunarpages - SharePoint Services (Beta)
===> Lunarpages - cPanel & WHM
===> Lunarpages - General
===> Lunarpages - Plesk
===> Lunarpages - Security
===> Lunarpages - Tutorials
===> Lunarpages - Webmin
===> Lunarpages - WHM
-----------------------------
Lunarpages Web Hosting - Coding
-----------------------------
=> Lunarpages - ASP
=> Lunarpages - C++ / PERL / CGI
=> Lunarpages - PHP & MySQL
=> Lunarpages - Java Applets & Javascript
=> Lunarpages - JSP & Servlets
=> Lunarpages - Ruby Hosting
=> Lunarpages - Windows Development & Hosting
-----------------------------
Lunarpages Web Hosting - Entertainment
-----------------------------
=> Lunarpages - Chat & Stuff!
=> Lunarpages - Contests
=> Fun at Lunarpages!!
=> Lunarpages - Online Gaming
-----------------------------
Lunarpages Web Hosting - General
-----------------------------
=> Social Networking
=> Lunarpages Free Web Hosting - Education Program
=> Lunarpages - Affiliate Program
=> Introduce Yourself to the Lunarpages Forum Community!
=> Your Websites & Creations at Lunarpages!
=> Lunarpages Website of the Month
=> Lunarpages - Service and Trade
Loading...