By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

html e-mail seding problem with php...

P: n/a
Hi to all,

I have the following html mail sender code written in php. It is
working properly but my problem is, code doesn't send the text
correctly which is in the varible "$mesaj". Code sends some unreadable
text. Any help would be appreciated, Thanx all.
Note: I put the sample image of the problem in:
http://www.wiliw.com/problem2.gif

Cem Louis

<?

$mesaj = "iİıIşŞğĞ";

$mailtext = "<html><head>";
$mailtext .= "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=windows-1254\">";
$mailtext .= "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=ISO-8859-9\">";
$mailtext .= "<meta http-equiv=\"content-language\" content=\"TR\">";
$mailtext .= "</head><body>";
$mailtext .= "$mesaj";
$mailtext .= "</body></html>";

$headers .= "MIME-Version: 1.0 \n" ;
$headers .= "From: the mailer<ma****@site.com> \n";
$headers .= "X-Sender:ma****@site.com \n";
$headers .= "X-Mailer:Mailing system (ab***@me.com) \n";
$headers .= "X-Priority: 3 \n";
$headers .= "Return-Path: ma****@site.com \n";
$headers .= "Content-Type:text/html;charset=windows-1254 \n";

$email_to = "re*******@site.com";
$frommail = "ma****@site.com";
$subject_line = "Got mail from the site!";

mail($email_to,$subject_line,$mailtext, $headers);

?>
Jul 17 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
On 9 Jul 2004 13:37:11 -0700, ce******@phreaker.net (Cem Louis) wrote:
Hi to all,

I have the following html mail sender code written in php. It is $mailtext .= "<meta http-equiv=\"Content-Type\" content=\"text/html;


Good mail sites sill dump your mails based on this.
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
DataBasix | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ۳
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Jul 17 '05 #2

P: n/a
On 9 Jul 2004 13:37:11 -0700, ce******@phreaker.net (Cem Louis) wrote:
$mailtext .= "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=windows-1254\">";
$mailtext .= "<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=ISO-8859-9\">";


Make up your mind which character set you're in?

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3

P: n/a
Cem Louis wrote:
$headers .= "MIME-Version: 1.0 \n" ;


Mail headers should be separated by CRLF (that's "\r\n" in PHP)

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #4

P: n/a
Hello

On 07/09/2004 05:37 PM, Cem Louis wrote:
Hi to all,

I have the following html mail sender code written in php. It is
working properly but my problem is, code doesn't send the text
correctly which is in the varible "$mesaj". Code sends some unreadable
text. Any help would be appreciated, Thanx all.
Note: I put the sample image of the problem in:
http://www.wiliw.com/problem2.gif


Messages with non-ASCII characters must be sent in quoted-printable
encoding.

You may want to take a look at this class that shows how to send
messages that way. It even comes with an example of how to send a
message in Japanese, but it could be any other idiom using any other
character set:

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #5

P: n/a
On Fri, 09 Jul 2004 18:15:19 -0300, Manuel Lemos <ml****@acm.org>
calmly ranted:
You may want to take a look at this class that shows how to send
messages that way. It even comes with an example of how to send a
message in Japanese, but it could be any other idiom using any other
character set:

http://www.phpclasses.org/mimemessage


Any progress on that update, Manuel?
--------------------------------------------
-- I'm in touch with my Inner Curmudgeon. --
http://diversify.com Comprehensive Website Development
================================================== ==========

Jul 17 '05 #6

P: n/a
Hello,

On 07/09/2004 09:54 PM, Larry Jaques wrote:
You may want to take a look at this class that shows how to send
messages that way. It even comes with an example of how to send a
message in Japanese, but it could be any other idiom using any other
character set:

http://www.phpclasses.org/mimemessage

Any progress on that update, Manuel?


What do you mean? The class supports quoted printable encoding and
custom character sets since a long time ago.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #7

P: n/a
Manuel Lemos <ml****@acm.org> wrote:
http://www.wiliw.com/problem2.gif


Messages with non-ASCII characters must be sent in quoted-printable
encoding.


This is not true for the body of a message, see rfc 2045 and look for
the 8bit and binary values for the content-transfer-encoding header.

--

Daniel Tryba

Jul 17 '05 #8

P: n/a
On Fri, 09 Jul 2004 22:04:27 -0300, Manuel Lemos <ml****@acm.org>
calmly ranted:
Hello,

On 07/09/2004 09:54 PM, Larry Jaques wrote:
You may want to take a look at this class that shows how to send
messages that way. It even comes with an example of how to send a
message in Japanese, but it could be any other idiom using any other
character set:

http://www.phpclasses.org/mimemessage

Any progress on that update, Manuel?


What do you mean? The class supports quoted printable encoding and
custom character sets since a long time ago.


How quickly they forget. ;)

-snip from 7/05 posts-
http://www.phpclasses.org/mimemessage

You provide a _very_ comprehensive class there, Manuel.
Do you by any chance have an instruction manual for it?
;)


Not yet. I can produce a reference manual soon from the class
auto-documentation. It would for instance like in this class:

http://www.phpclasses.org/xmlwriter

It will take me a few days. Just let me know if that would be useful.

Yes, please, VERY. I told my client I'd have her HTML newsletter up


It is almost done and I will probably release it later today, but if
you are in a hurry, you should look at the example scripts supplied
with the class.
-snip-

Now that things are back in context, how's it coming?
--------------------------------------------
-- I'm in touch with my Inner Curmudgeon. --
http://diversify.com Comprehensive Website Development
================================================== ==========

Jul 17 '05 #9

P: n/a
Hello,

On 07/10/2004 05:11 AM, Daniel Tryba wrote:
Manuel Lemos <ml****@acm.org> wrote:
http://www.wiliw.com/problem2.gif


Messages with non-ASCII characters must be sent in quoted-printable
encoding.

This is not true for the body of a message, see rfc 2045 and look for
the 8bit and binary values for the content-transfer-encoding header.


Sorry, you cannot assume that the MTA that will get the message will
support 8 bit encoded messages or else your messages may get discarded
and then you wonder why the messages were not accepted. It is better to
play safe and let MTA convert to 8 bit when it knows it can do that.
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #10

P: n/a
Hello,

On 07/10/2004 11:47 AM, Larry Jaques wrote:
>http://www.phpclasses.org/mimemessage

You provide a _very_ comprehensive class there, Manuel.
Do you by any chance have an instruction manual for it?
;)

Not yet. I can produce a reference manual soon from the class
auto-documentation. It would for instance like in this class:

http://www.phpclasses.org/xmlwriter

It will take me a few days. Just let me know if that would be useful.

Yes, please, VERY. I told my client I'd have her HTML newsletter up

It is almost done and I will probably release it later today, but if
you are in a hurry, you should look at the example scripts supplied
with the class.
-snip-

Now that things are back in context, how's it coming?


Sorry, extensive documentation is available on the site since late
Wednesday. I assummed that you were getting automatic notifications of
update of the class that goes to all subscribers that have previously
downloaded the class.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #11

P: n/a
On Sat, 10 Jul 2004 14:36:57 -0300, Manuel Lemos <ml****@acm.org>
calmly ranted:
Sorry, extensive documentation is available on the site since late
Wednesday. I assummed that you were getting automatic notifications of
update of the class that goes to all subscribers that have previously
downloaded the class.


No, I hadn't/haven't. I'll redownload it now and turn the
notifications back on while I'm there. Thanks.
--------------------------------------------
-- I'm in touch with my Inner Curmudgeon. --
http://diversify.com Comprehensive Website Development
================================================== ==========

Jul 17 '05 #12

P: n/a
Manuel Lemos wrote:
Hello,

On 07/10/2004 05:11 AM, Daniel Tryba wrote:
Manuel Lemos <ml****@acm.org> wrote:
http://www.wiliw.com/problem2.gif
Messages with non-ASCII characters must be sent in quoted-printable
encoding.


This is not true for the body of a message, see rfc 2045 and look for
the 8bit and binary values for the content-transfer-encoding header.

Sorry, you cannot assume that the MTA that will get the message will
support 8 bit encoded messages or else your messages may get discarded
and then you wonder why the messages were not accepted. It is better to
play safe and let MTA convert to 8 bit when it knows it can do that.


And I would not assume that the email reader can understand HTML. Email
is best sent in ascii-text and if the MTA wants to convert it to HTML,
then it can...

Personally, I hate HTML mail -mainly because I primarily use a
ascii-text only reader - the other is security related.

Michael Austin.
Jul 17 '05 #13

P: n/a
Hello,

On 07/11/2004 11:33 PM, Michael Austin wrote:
Messages with non-ASCII characters must be sent in quoted-printable
encoding.


This is not true for the body of a message, see rfc 2045 and look for
the 8bit and binary values for the content-transfer-encoding header.
Sorry, you cannot assume that the MTA that will get the message will
support 8 bit encoded messages or else your messages may get discarded
and then you wonder why the messages were not accepted. It is better
to play safe and let MTA convert to 8 bit when it knows it can do that.


And I would not assume that the email reader can understand HTML. Email
is best sent in ascii-text and if the MTA wants to convert it to HTML,
then it can...


That is why you need to compose multipart/alternative to send HTML
properly because these can include both the plain text and HTML versions
that are displayed correctly depending on what your e-mail client can
display.

Every decent e-mail program can send messages this way. In PHP, you can
use the same class that I mentioned to compose it properly.

http://www.phpclasses.org/mimemessage
Personally, I hate HTML mail -mainly because I primarily use a
ascii-text only reader - the other is security related.


If you disable Javascript and objects that require plug-ins for viewing
HTML e-mail you are safe. If your concern is privacy (different than
security) you may use a cookies disabled mail program. I use Mozilla
Mail but you may prefer a smaller client.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #14

P: n/a
Manuel Lemos <ml****@acm.org> wrote:
This is not true for the body of a message, see rfc 2045 and look for
the 8bit and binary values for the content-transfer-encoding header.
Sorry, you cannot assume that the MTA that will get the message will
support 8 bit encoded messages or else your messages may get discarded
and then you wonder why the messages were not accepted.


Let's all stay in the stone age :)

It's a valid rfc, especially when one is going to use mime for html
attachments, so decent software should implement it.
It is better to play safe and let MTA convert to 8 bit when it knows
it can do that.


My terminal doesn't do 8bit, so nobody should use non-ascii characters
anywhere.

BTW although I personally don't have any unicode characterset installed,
I advocate the use of unicode (and utf-8 or utf-7 to transport it
safely).

--

Daniel Tryba

Jul 17 '05 #15

P: n/a
Hello,

On 07/12/2004 08:36 PM, Daniel Tryba wrote:
This is not true for the body of a message, see rfc 2045 and look for
the 8bit and binary values for the content-transfer-encoding header.
Sorry, you cannot assume that the MTA that will get the message will
support 8 bit encoded messages or else your messages may get discarded
and then you wonder why the messages were not accepted.

Let's all stay in the stone age :)

It's a valid rfc, especially when one is going to use mime for html
attachments, so decent software should implement it.


I don't think you understand the problem. Composing and sending messages
are usually separate steps. You only know if the SMTP server that
receives the message supports the 8 bit encoded messages after you
connect to it and query its capabilities. Since composition is done
before that, you can't make any assumptions when you compose the messages.

As long as you have software capable of composing messages encoded in 7
bit (ASCII), why bother trying to encode them with 8 bit characters?

If the receiving SMTP server thinks it is worth converting the messages
to an 8 bit encoding, let it do it at its own risk.

It is better to play safe and let MTA convert to 8 bit when it knows
it can do that.

My terminal doesn't do 8bit, so nobody should use non-ascii characters
anywhere.


If you only understand english, it probably does not make sense to
expect non ASCII messages. That is a problem of who reads the messages
not the MTA.
BTW although I personally don't have any unicode characterset installed,
I advocate the use of unicode (and utf-8 or utf-7 to transport it
safely).


I think you are confusing character sets with encodings. Unicode define
a character set that may be encoded as utf-8 or utf-7. You can use any 8
bit character set and encode it with quoted printable.

Quoted printable is what you should use to compose messages, not only
because the encoded messages only carry 7 bit characters despite they
may represent 8 bit text, but also it assures that the encoded message
lines do not exceed 75 characters even thouugh the text it self may have
lines of arbitrary length.
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.