Hi there,

Thanks for the help, I've sorted it out now - stupid me :-)  You know what
it's like sometimes, you work that hard on different things that something
which should be really simple just goes over your head - well, it does mine
anyway :-)

Very much appreciated.


Hey Chris,

Probably a good idea would be to read the email RFC.

I'd say that you're trying to send a Multi-part MIME email, but not
formatting it correctly. You even forget to include your 'simple' (plain
text) message in the email body. SO if you were formatting it correctly, and
your friend is only viewing plain text, you won't see anything.

Here's the basic structure of a Multi-part MIME email:

---- begin quote ----
From:  Persons Name <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-type: multipart/alternative; boundary=mime_seperator
X-Mailer: PHP/5.0.0
This is a multi-part message in MIME format.

Content-type: text/plain;    charset=us-ascii
Content-Transfer-Encoding: 7bit
This is the plain text part of the email.

Content-type: text/html;    charset=us-ascii
Content-Transfer-Encoding: 7bit

HTML Email  in here


---- end quote ----

A few notes for you:

1. "This is a multi-part message in MIME format." begins the email body. (ie
it's not a header)
2. Most of the headers need \r\n as a newline. \n won't do. (Checkout the
code below to see where to use \r\n and where to use \n)
3. You need a mime seperator to begin each section of the email. it should
be preceded by -- each time. You should end the email with the mime
seperator preceeded with -- AND suffixed with -. You can use pretty much
anything for the seperator. There may be a restriction on which characters
you can use.
4. This does not cover attachments. If you want to send attachments in the
email, you need to do some further research.

Official EMail RFCs:

Here's a great tutorial at "PHP Builder":

Here's how I do the above email:

  $myname="My Name";
  $my_email="[EMAIL PROTECTED]";
  $username="Person's Name";
  $user_email="<[EMAIL PROTECTED]";
  $subject="General Subject";
  $extra_headers="From: $myname <$my_email> \r\nMIME-Version:
1.0\r\nContent-type: multipart/alternative;
boundary=\"$content_boundary\"\r\nX-Mailer: PHP/".phpversion();
text/html;\tcharset=\"us-ascii\"\nContent-Transfer-Encoding: 7bit\n\n";
text/plain;\tcharset=\"us-ascii\"\nContent-Transfer-Encoding: 7bit\n\n";
  $message="This is a multi-part message in MIME format.\r\n\r\n";
  $message.="Plain text email.\r\nA new line\r\n\r\nTwo new lines follwed by
some more text."
  $message.="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
  $message.="Message body in here";
  mail($username."<".$user_email.">", $subject, $message, $extra_headers);

Hope this helps.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to