Problems with mail()

This is a discussion on Problems with mail() within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Im having a formatting issue with mail(). My simple script looks like: $key = blah@blah.com; $subject = "My membership&...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-09-2003
Ryan Ramsey
 
Posts: n/a
Default Problems with mail()

Im having a formatting issue with mail().

My simple script looks like:

$key = blah@blah.com;
$subject = "My membership";
$message_to_send = "<strong>Hello".$key."</strong>";

mail($key, $subject, $message_to_send, "From: blah@blah.com");

When it comes to my email client it appears as:

<strong>Hello blah@blah.com</strong>

Instead of:

Hello blah@blah.com

I have also tried adding <html> and <body> tags but that doesn't seem to do anything.
I get other HMTL messages from amazon and such but it would appear that one generated from mail() is sending only raw text.
How do I get it to format HTML based message?


Reply With Quote
  #2 (permalink)  
Old 07-09-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: Problems with mail()


"Ryan Ramsey" <ryanramsey@yahoo.com> schreef in bericht
news:bhZOa.875$5o5.577540@news1.news.adelphia.net. ..
> Im having a formatting issue with mail().
>
>My simple script looks like:
>

.....
>When it comes to my email client it appears as:
> <strong>Hello blah@blah.com</strong>
>
>Instead of:
> Hello blah@blah.com


First of all: DO NOT send HTML mail to newsgroups!!! In your e-mail client
there's a setting which allows you to select plain text a-mails for
newsgroups and HTML for others.

To answer your question: Use the the fourth argument of the mail() function
to send a content type header with text/html as the value:

mail($key, $subject, $message_to_send, "From: blah@blah.com\nContent-Type:
text/html");


JW



Reply With Quote
  #3 (permalink)  
Old 07-09-2003
Ryan Ramsey
 
Posts: n/a
Default Re: Problems with mail()

Ok here is another question...

It would seem that the mail() is injecting a "! " in the text of
$message_to_sender:

So text that should read:

There once were three bears that lived in a big black house.

Would look like:

There once were three bears that lived in a big blac! k house

Does this look familiar? Does mail() have an issue with the size of the
message being passed? If I increase the size of the text, the "! " will move
accordingly (im guessing at char 255).


"Esteban Fernández" <eft0@gmx.nospam.net> wrote in message
news:3f0c7ed3@omega.ifxnw.cl...
> Easy, just replace you mail line code, for thi one.
>
> mail($key, $subject, $message_to_send, "Content-Type: text/html\nFrom:
> blah@blah.com");
>
> Regards.
> EF.
>
>
> "Ryan Ramsey" <ryanramsey@yahoo.com> escribió en el mensaje
> news:bhZOa.875$5o5.577540@news1.news.adelphia.net. ..
> Im having a formatting issue with mail().
>
> My simple script looks like:
>
> $key = blah@blah.com;
> $subject = "My membership";
> $message_to_send = "<strong>Hello".$key."</strong>";
>
> mail($key, $subject, $message_to_send, "From: blah@blah.com");
>
> When it comes to my email client it appears as:
>
> <strong>Hello blah@blah.com</strong>
>
> Instead of:
>
> Hello blah@blah.com
>
> I have also tried adding <html> and <body> tags but that doesn't seem to

do
> anything.
> I get other HMTL messages from amazon and such but it would appear that

one
> generated from mail() is sending only raw text.
> How do I get it to format HTML based message?
>
>
>



Reply With Quote
  #4 (permalink)  
Old 07-10-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: Problems with mail()


"Ryan Ramsey" <ryanramsey@yahoo.com> wrote in message
news:xL0Pa.1079$5o5.639092@news1.news.adelphia.net ...
> Ok here is another question...
>
> It would seem that the mail() is injecting a "! " in the text of
> $message_to_sender:
>
> So text that should read:
>
> There once were three bears that lived in a big black house.
>
> Would look like:
>
> There once were three bears that lived in a big blac! k house
>
> Does this look familiar? Does mail() have an issue with the size of the
> message being passed? If I increase the size of the text, the "! " will

move
> accordingly (im guessing at char 255).
>


A simple "Content-Type: text/html;charset=ISO-8859-1\n" should fix this.

JW



Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:26 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0