473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 7987
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.