472,951 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

PHP, mail and multi-mime types

I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?

TIA,

Gary Smith

<?php
// generate MIME boundary
echo uniqid(time())."<br>";
$boundary = "----=".md5(uniqid(time()))."";

// set email headers
$header = "Return-Path: ja********@adndrealm.net\r\n";
$header.= "From: Theo <ja********@adndrealm.net>\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: multipart/alternative;\r\n
boundary=\"$boundary\"\r\n";
// set text section
$txt_head = $boundary."\r\n";
$txt_head.= "Content-Type: text/plain;\r\n
charset=\"iso-8859-1\"\r\n";
$txt_head.= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$txt_head.= "some simple text\r\n";
// set html section
$htm_head = $boundary."\r\n";
$htm_head.= "Content-Type: text/html;\r\n
charset=\"iso-8859-1\"\r\n";
$htm_head.= "Content-Transfer-Encoding: quoted-printables\r\n\r\n";
$htm_head.= "<html><body><font
size=3>Hello</font></body></html>\r\n\r\n";
// combine headers & message
$mesg = $txt_head.$htm_head.$boundary."--";
// send email out
mail ("ja********@adndrealm.net","test with dual
encoding",$mesg,$header);

?>
Jul 17 '05 #1
3 7968
Gary Smith wrote:
I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?


[Snip code]

From the typos, misunderstandings, or just plain mistakes -- I can't
discern which is which -- I'd suggest you either (re)read RFCs 2045-
49 or use a purpose-built class[1]. If I were you, I'd reconsider
using pseudo-HTML at all in email.
[1] I can't vouch for it, but
http://www.phpclasses.org/mimemessage

--
Jock
Jul 17 '05 #2
"Gary Smith" <ga********@primeexalia.com> wrote in message
news:2e**************************@posting.google.c om...
I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?

TIA,

Gary Smith

<?php
// generate MIME boundary
echo uniqid(time())."<br>";
$boundary = "----=".md5(uniqid(time()))."";

// set email headers
$header = "Return-Path: ja********@adndrealm.net\r\n";
$header.= "From: Theo <ja********@adndrealm.net>\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: multipart/alternative;\r\n
boundary=\"$boundary\"\r\n";
// set text section
$txt_head = $boundary."\r\n";
$txt_head.= "Content-Type: text/plain;\r\n
charset=\"iso-8859-1\"\r\n";
$txt_head.= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$txt_head.= "some simple text\r\n";
// set html section
$htm_head = $boundary."\r\n";
$htm_head.= "Content-Type: text/html;\r\n
charset=\"iso-8859-1\"\r\n";
$htm_head.= "Content-Transfer-Encoding: quoted-printables\r\n\r\n";
$htm_head.= "<html><body><font
size=3>Hello</font></body></html>\r\n\r\n";
// combine headers & message
$mesg = $txt_head.$htm_head.$boundary."--";
// send email out
mail ("ja********@adndrealm.net","test with dual
encoding",$mesg,$header);

?>


Look at the complete email that is sent, and look for errors there.

try this also:
http://www.gzentools.com/snippetview...send-email.php
--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #3
I found my bug prior to your posting (it was the boundary requiring an
additional "--" prior to each segment. Just something I overlooked I
guess.

The sample in the link is much better than mine so I'll just
snippet... :)


try this also:
http://www.gzentools.com/snippetview...send-email.php


Thanks,

Gary
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jim Seymour | last post by:
I have a contact form that uses PHP's mail() function. It recently came to my attention that (some?) MS-Windows mail servers may not properly process data given to the mail() function that's only...
1
by: Gernot Hillier | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! I'm the developer of a Linux ISDN application which uses embedded Python for controlling the communication. It starts several threads (i.e....
0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
1
by: Varun Sud | last post by:
Hi, I have written an article declaring and using multi-dimensional pointers in C++. The article tries to address many of the issues related to multi-dimensional pointers asked in the forum. ...
2
by: Victor Nazarov | last post by:
Assuming my locale has enough info about codepage and multi-byte charecters, how should I compare (collate) multi-byte strings (strings of multi-byte charecters with zero-byte at the end) in ISO...
5
by: Duncan Mole | last post by:
Hi all, Does anyone know of a way to achieve multi-theaded platform invokes? I have been taking quite a performance hit using the syncronised attribute: . Cheers ---
1
by: Alf P. Steinbach | last post by:
* Adam, in clc++m: > I have an unfortunate case where a single class wants to derive from two > existing classes: > > struct A { virtual long fun() = 0; }; > struct B { virtual bool fun() =...
0
by: misra | last post by:
Hi, I am using a C# code to call blat and send mail. When I send mails with long sentences, the mail automatically is send with multiple lines. However, certain times the body and format of the...
7
by: kimiraikkonen | last post by:
Hello experts, I've been already working on a project and also asked and i've managed to create a basic Gmail mail sender, but i want to add a progressbar that shows "sending is in progress" but...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.