[PHP] Create multipart email

2009-05-28 Thread Guus Ellenkamp
I'm trying to attach an uploaded file to an e-mail which I receive in 
Outlook. Neither the first part, nor the second part displays properly. The 
header looks ok when displayed on the screen. What am I missing?

See code below.
function xmail($mailto, $from_mail, $from_name, $replyto, $subject, 
$message, $origname, $tempfile, $filetype) {

$file = $tempfile;

$file_size = filesize($file);

$handle = fopen($file, "r");

$content = fread($handle, $file_size);

fclose($handle);

$content = chunk_split(base64_encode($content));

$uid = md5(uniqid(time()));

$name = basename($origname);

$header = "From: ".$from_name." <".$from_mail.">\r\n";

$header .= "Reply-To: ".$replyto."\r\n";

$header .= "MIME-Version: 1.0\r\n";

$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";

$header .= "This is a multi-part message in MIME format.\r\n";

$header .= "--".$uid."\r\n";

$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";

$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";

$header .= $message."\r\n\r\n";

$header .= "--".$uid."\r\n";

$header .= "Content-Type: ".$filetype."; name=\"".$name."\"\r\n"; // use 
diff. tyoes here

$header .= "Content-Transfer-Encoding: base64\r\n";

$header .= "Content-Disposition: attachment; file=\"".$name."\"\r\n\r\n";

$header .= $content."\r\n\r\n";

$header .= "--".$uid."--";

echo $header;

if (mail($mailto, $subject, "test", $header)) {

echo "mail send ... OK"; // or use booleans here

} else {

echo "mail send ... ERROR!";

}

}

// how to use

$my_name = "Guus";

$my_mail = "g...@activediscovery.net";

$my_replyto = "g...@activediscovery.net";

$my_subject = "This is a mail with attachment.";

$my_message = "Hallo,\r\ndo you like this script? I hope it will 
help.\r\n\r\ngr. Olaf";

xmail("g...@activediscovery.net", $my_mail, $my_name, $my_replyto, 
$my_subject, $my_message,$fileName, $fileTempName, $fileType);



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



Re: [PHP] Create multipart email

2009-06-02 Thread Guus Ellenkamp
Thanks. I tried and it seems quite straightforward. However, I get the 
message 'could not instantiate mail function'. Seemed to have something to 
do with the 'to' address, but could not figure out what exactly. Also 
searched the internet, but did not find the solution. Any suggestion?

"Phpster"  wrote in message 
news:aa68d580-47d1-4bac-a18b-c98772aaf...@gmail.com...
> Use phpmailer, makes it simple
>
> Bastien
>
> Sent from my iPod
>
> On May 28, 2009, at 4:47, "Guus Ellenkamp"   
> wrote:
>
>> I'm trying to attach an uploaded file to an e-mail which I receive in
>> Outlook. Neither the first part, nor the second part displays  properly. 
>> The
>> header looks ok when displayed on the screen. What am I missing?
>>
>> See code below.
>> function xmail($mailto, $from_mail, $from_name, $replyto, $subject,
>> $message, $origname, $tempfile, $filetype) {
>>
>> $file = $tempfile;
>>
>> $file_size = filesize($file);
>>
>> $handle = fopen($file, "r");
>>
>> $content = fread($handle, $file_size);
>>
>> fclose($handle);
>>
>> $content = chunk_split(base64_encode($content));
>>
>> $uid = md5(uniqid(time()));
>>
>> $name = basename($origname);
>>
>> $header = "From: ".$from_name." <".$from_mail.">\r\n";
>>
>> $header .= "Reply-To: ".$replyto."\r\n";
>>
>> $header .= "MIME-Version: 1.0\r\n";
>>
>> $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n 
>> \r\n";
>>
>> $header .= "This is a multi-part message in MIME format.\r\n";
>>
>> $header .= "--".$uid."\r\n";
>>
>> $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
>>
>> $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
>>
>> $header .= $message."\r\n\r\n";
>>
>> $header .= "--".$uid."\r\n";
>>
>> $header .= "Content-Type: ".$filetype."; name=\"".$name."\"\r\n"; //  use
>> diff. tyoes here
>>
>> $header .= "Content-Transfer-Encoding: base64\r\n";
>>
>> $header .= "Content-Disposition: attachment; file=\"".$name."\"\r\n\r 
>> \n";
>>
>> $header .= $content."\r\n\r\n";
>>
>> $header .= "--".$uid."--";
>>
>> echo $header;
>>
>> if (mail($mailto, $subject, "test", $header)) {
>>
>> echo "mail send ... OK"; // or use booleans here
>>
>> } else {
>>
>> echo "mail send ... ERROR!";
>>
>> }
>>
>> }
>>
>> // how to use
>>
>> $my_name = "Guus";
>>
>> $my_mail = "g...@activediscovery.net";
>>
>> $my_replyto = "g...@activediscovery.net";
>>
>> $my_subject = "This is a mail with attachment.";
>>
>> $my_message = "Hallo,\r\ndo you like this script? I hope it will
>> help.\r\n\r\ngr. Olaf";
>>
>> xmail("g...@activediscovery.net", $my_mail, $my_name, $my_replyto,
>> $my_subject, $my_message,$fileName, $fileTempName, $fileType);
>>
>>
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 



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



Re: [PHP] Create multipart email

2009-06-02 Thread Guus Ellenkamp
A bit of overkill, but it seems to work. Thanks!

"Eric Butera"  wrote in message 
news:6a8639eb0905280823r162f91a0v15725e0dc7543...@mail.gmail.com...
> On Thu, May 28, 2009 at 4:47 AM, Guus Ellenkamp
>  wrote:
>> I'm trying to attach an uploaded file to an e-mail which I receive in
>> Outlook. Neither the first part, nor the second part displays properly. 
>> The
>> header looks ok when displayed on the screen. What am I missing?
>
> If you value your time then use Zend_Mail and be done with it.  :D 



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



[PHP] Encoding problem

2007-02-05 Thread Guus Ellenkamp
I have a string with an n with a tilde. mb_detect_encoding says it's UTF-8. 
I set the http encoding to UTF-8 and also the internal encoding. However, I 
cannot produce proper output with echo $varwithtilde.

echo  $returnArray[$i]->address1.' has 
'.mb_detect_encoding($returnArray[$i]->address1)
does NOT produce correct output in a browser or with the W3C validator, 
although it says the encoding of the var is UTF-8.

What's wrong?

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



Re: [PHP] Encoding problem

2007-02-05 Thread Guus Ellenkamp
The document IS UTF-8. The character does not seem to be. It comes from a 
mySQL database. However, also the database settings are also UTF-8. The 
field was entered into the database with phpMyAdmin. I tried it now local on 
my test-system and remote, so the database itself does not seem to be the 
problem. Could it be phpMyAdmin?

"Jon Anderson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Guus Ellenkamp wrote:
>> I have a string with an n with a tilde. mb_detect_encoding says it's 
>> UTF-8. I set the http encoding to UTF-8 and also the internal encoding. 
>> However, I cannot produce proper output with echo $varwithtilde.
>>
>> echo  $returnArray[$i]->address1.' has 
>> '.mb_detect_encoding($returnArray[$i]->address1)
>> does NOT produce correct output in a browser or with the W3C validator, 
>> although it says the encoding of the var is UTF-8.
>>
>> What's wrong?
>>
> Character set issues can be very complex, but I'm going to take a 
> guess
>
> If you're outputting something that is actually UTF-8, you'll need to make 
> sure that you've done these:
>
> header('Content-Type: text/html; charset=utf-8');
>
> I believe that IE6 requires this one as well within your html head.
>
> 
>
> If that doesn't work, then it could be that your character isn't actually 
> UTF-8 encoded.
>
> jon 

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



Re: [PHP] Encoding problem

2007-02-05 Thread Guus Ellenkamp
Found it. Have to use:

mysql_query("SET CHARACTER SET 'utf8'", $link);

""Guus Ellenkamp"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> The document IS UTF-8. The character does not seem to be. It comes from a 
> mySQL database. However, also the database settings are also UTF-8. The 
> field was entered into the database with phpMyAdmin. I tried it now local 
> on my test-system and remote, so the database itself does not seem to be 
> the problem. Could it be phpMyAdmin?
>
> "Jon Anderson" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Guus Ellenkamp wrote:
>>> I have a string with an n with a tilde. mb_detect_encoding says it's 
>>> UTF-8. I set the http encoding to UTF-8 and also the internal encoding. 
>>> However, I cannot produce proper output with echo $varwithtilde.
>>>
>>> echo  $returnArray[$i]->address1.' has 
>>> '.mb_detect_encoding($returnArray[$i]->address1)
>>> does NOT produce correct output in a browser or with the W3C validator, 
>>> although it says the encoding of the var is UTF-8.
>>>
>>> What's wrong?
>>>
>> Character set issues can be very complex, but I'm going to take a 
>> guess
>>
>> If you're outputting something that is actually UTF-8, you'll need to 
>> make sure that you've done these:
>>
>> header('Content-Type: text/html; charset=utf-8');
>>
>> I believe that IE6 requires this one as well within your html head.
>>
>> 
>>
>> If that doesn't work, then it could be that your character isn't actually 
>> UTF-8 encoded.
>>
>> jon 

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



[PHP] How to set Content-type text/plain

2010-03-26 Thread Guus Ellenkamp
I have the following lines in my PHP code:

header('Content-type: text/plain; charset=utf-8');
echo 'Invalid command';

However, the output is:

HTTP/1.1 200 OK
Date: Fri, 26 Mar 2010 13:30:08 GMT
Server: Apache/2.0.55 (Win32) PHP/5.1.4
X-Powered-By: PHP/5.1.4
Set-Cookie: 
http://groepskorting.megaheights.net_sfx=j1cujiemeelf4iqpepqlqub5n3;
 path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0
Pragma: no-cache
Set-Cookie: 98defd6ee70dfb1dea416cecdf391f58=-; path=/
Content-Length: 13
Content-Type: text/html

 Invalid task

Why is the Content-Type text/html and not text/plain? 



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



Re: [PHP] How to set Content-type text/plain

2010-03-26 Thread Guus Ellenkamp
Sorry, my mistake... Never trapped a computer on this kind of mistakes. I 
never arrived at those lines hehehehe. Sorry.

Robert, thanks, you brought the idea to check further.

"Robert Cummings"  wrote in message 
news:4bacba3f.6050...@interjinn.com...
> Guus Ellenkamp wrote:
>> I have the following lines in my PHP code:
>>
>> header('Content-type: text/plain; charset=utf-8');
>> echo 'Invalid command';
>>
>> However, the output is:
>>
>> HTTP/1.1 200 OK
>> Date: Fri, 26 Mar 2010 13:30:08 GMT
>> Server: Apache/2.0.55 (Win32) PHP/5.1.4
>> X-Powered-By: PHP/5.1.4
>> Set-Cookie: 
>> http://groepskorting.megaheights.net_sfx=j1cujiemeelf4iqpepqlqub5n3;
>>  path=/
>> Expires: Thu, 19 Nov 1981 08:52:00 GMT
>> Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
>> pre-check=0
>> Pragma: no-cache
>> Set-Cookie: 98defd6ee70dfb1dea416cecdf391f58=-; path=/
>> Content-Length: 13
>> Content-Type: text/html
>>
>>  Invalid task
>>
>> Why is the Content-Type text/html and not text/plain?
>
> Is another header sent later in the program flow? It would supercede 
> previous headers. Try setting the replace parameter in the call to false 
> and then check the head response.
>
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 



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



[PHP] Convert UTF-8 to PHP defines

2010-05-26 Thread Guus Ellenkamp
We use PHP defines for defining text in different languages. As far as I 
know PHP files are supposed to be ASCII, not UTF-8 or something like that. 
What I want to make is a conversion program that would convert a given UTF-8 
file with the format

definetext1=this is a text in random UTF-8, probably arabic or similar text
definetext2=this is another text in random UTF-8, probably arabic or similar 
text

into a file with the following defines

define('definetext1',chr().chr().chr()...).chr());
define('definetext2,chr().chr().chr()...).chr());

Not sure if I'm using the correct chr/ord function, but I hope the above is 
clear enough to make clear what I'm looking for. Basically the output file 
should be ascii and not contain any utf-8.

Any advise? The html_special_chars did not seem to work for Vietnamese text 
I tried to convert, so something seems to get wrong with just reading an 
array of strings and converting the strings and putting them in defines. 



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



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Guus Ellenkamp
Thanks, but are you sure of that? I did some research a while ago and found 
that officially PHP files should be ascii and not have any specific 
character encoding. I believe it will work anyhow (did not try this one), 
but would like to stick with the standards.

"Ashley Sheridan"  wrote in message 
news:1274883714.2202.228.ca...@localhost...
> On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
>
>> We use PHP defines for defining text in different languages. As far as I
>> know PHP files are supposed to be ASCII, not UTF-8 or something like 
>> that.
>> What I want to make is a conversion program that would convert a given 
>> UTF-8
>> file with the format
>>
>> definetext1=this is a text in random UTF-8, probably arabic or similar 
>> text
>> definetext2=this is another text in random UTF-8, probably arabic or 
>> similar
>> text
>>
>> into a file with the following defines
>>
>> define('definetext1',chr().chr().chr()...).chr());
>> define('definetext2,chr().chr().chr()...).chr());
>>
>> Not sure if I'm using the correct chr/ord function, but I hope the above 
>> is
>> clear enough to make clear what I'm looking for. Basically the output 
>> file
>> should be ascii and not contain any utf-8.
>>
>> Any advise? The html_special_chars did not seem to work for Vietnamese 
>> text
>> I tried to convert, so something seems to get wrong with just reading an
>> array of strings and converting the strings and putting them in defines.
>>
>>
>>
>
>
> PHP files can contain utf-8, and in-fact is the preference of most
> developers I know of.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
> 



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



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Guus Ellenkamp
And I need(ed) this stuff especially for non-ASCII characters like Chinese, 
Arabic and stuff :)

"Ashley Sheridan"  wrote in message 
news:1274976794.2202.274.ca...@localhost...
On Thu, 2010-05-27 at 12:08 -0400, Adam Richardson wrote:

> On Thu, May 27, 2010 at 9:45 AM, Guus Ellenkamp
> wrote:
>
> > Thanks, but are you sure of that? I did some research a while ago and 
> > found
> > that officially PHP files should be ascii and not have any specific
> > character encoding. I believe it will work anyhow (did not try this 
> > one),
> > but would like to stick with the standards.
> >
> > "Ashley Sheridan"  wrote in message
> > news:1274883714.2202.228.ca...@localhost...
> > > On Wed, 2010-05-26 at 22:20 +0800, Guus Ellenkamp wrote:
> > >
> > >> We use PHP defines for defining text in different languages. As far 
> > >> as I
> > >> know PHP files are supposed to be ASCII, not UTF-8 or something like
> > >> that.
> > >> What I want to make is a conversion program that would convert a 
> > >> given
> > >> UTF-8
> > >> file with the format
> > >>
> > >> definetext1=this is a text in random UTF-8, probably arabic or 
> > >> similar
> > >> text
> > >> definetext2=this is another text in random UTF-8, probably arabic or
> > >> similar
> > >> text
> > >>
> > >> into a file with the following defines
> > >>
> > >>
> > define('definetext1',chr().chr().chr()...).chr());
> > >>
> > define('definetext2,chr().chr().chr()...).chr());
> > >>
> > >> Not sure if I'm using the correct chr/ord function, but I hope the 
> > >> above
> > >> is
> > >> clear enough to make clear what I'm looking for. Basically the output
> > >> file
> > >> should be ascii and not contain any utf-8.
> > >>
> > >> Any advise? The html_special_chars did not seem to work for 
> > >> Vietnamese
> > >> text
> > >> I tried to convert, so something seems to get wrong with just reading 
> > >> an
> > >> array of strings and converting the strings and putting them in 
> > >> defines.
> > >>
> > >>
> > >>
> > >
> > >
> > > PHP files can contain utf-8, and in-fact is the preference of most
> > > developers I know of.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> Because the lower range of UTF-8 matches the ascii character set
> (intentionally by design), you'll be able to use UTF-8 for PHP files 
> without
> problem (i.e., ascii 7-bit chars have same encoding in UTF-8.)
> http://www.cl.cam.ac.uk/~mgk25/unicode.html
>
> However, if you were to use any of the multibyte characters of UTF-8 in a
> PHP file, you could run in to some trouble.  I use UTF-8 for most of my 
> PHP
> files, but I've been sticking to the ASCII subset exclusively.
>
> Adam
>


I don't use the higher range of characters often, but I do sometimes use
them for things like the graphical glyphs (½??, etc) I know I could do
those with regular text and the Wingdings font, but that's not available
on every computer, and breaks the semantic meaning behind the glyphs.

Thanks,
Ash
http://www.ashleysheridan.co.uk





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



Re: [PHP] Convert UTF-8 to PHP defines

2010-05-27 Thread Guus Ellenkamp
I would like if you stick to the original issue: can a PHP source file be in 
utf-8. It's not about the output, that is properly supported.

Think it would be a good idea anyhow that PHP would support utf-8 source 
files as it seems utf-8 is going to be the de-facto standard for text files 
anyhow.

"Ashley Sheridan"  wrote in message 
news:1274988834.2202.285.ca...@localhost...
> On Thu, 2010-05-27 at 15:28 -0400, Bob McConnell wrote:
>
>> From: tedd
>>
>> > The Unicode database uses the same lower
>> > character values (i.e., "code points") as does
>> > ASCII, namely 0-127, and thus UFT-8 (8-bit
>> > variable width encoding) is really a super-set
>> > which includes the sub-set of ASCII.
>> >
>> > The "Wingdings" font that Ash refers to is the
>> > really the "Dingbat" char set in Unicode, as
>> > shown here:
>> >
>> > The use of UFT-8 encoding in everything (web and
>> > php) should present much less problems globally
>> > than it is trying to fight it.
>>
>> Thanks tedd,
>>
>> The real question is whether unicode is even relevant now that the UTF
>> series is available. I see no reason to have to deal with two competing
>> "specifications", when one of them is more than adequate for the job and
>> the other is not even finished yet. That's like the old days when a few
>> users demanded we support both ASCII and EBCDIC. That didn't get very
>> far either.
>>
>> Bob McConnell
>>
>
>
> Bob, UTF is unicode (Unicode Transformation Format)
>
> Interesting enough to note, and not sure if Tedd knows this or not (he
> probably does!) but Chrome has a nice feature for those punycode URLs;
> it suggests the actual real URL instead once you type the domain in. Not
> sure about Safari right now, couldn't be bothered to fire up a VM just
> to check. I would assume Firefox handles these URLs well enough too.
>
> Tedd, does that URL actually go anywhere, as I got nothing when I tried
> visiting it, both the actual URL and the punycode version.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
> 



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



[PHP] cache_control_limiter

2010-07-06 Thread Guus Ellenkamp
I'm trying to set the cache_control_limiter to public, but it seems to stay 
in nocache. What can be wrong? Tried two servers. 



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



Re: [PHP] cache_control_limiter

2010-07-06 Thread Guus Ellenkamp
Thanks for the reply. I'm able to manipulate it with ini_set. However, 
according the documentation I should also be able to manipulate it with the 
function. Is it a bug?


"Alexandre SIMON"  wrote in message 
news:aanlktinxc9ejxvf2xd7hj_92r3y2yxalzvntjvcll...@mail.gmail.com...
> If you want to manipulate cache control on PHP side, you must set PHP
> directive "session.cache_limiter" to an empty value. Be then sure to 
> always
> set cache control headers to the right value according what your scripts 
> do.
>
> 2010/7/6 Guus Ellenkamp 
>
>> I'm trying to set the cache_control_limiter to public, but it seems to 
>> stay
>> in nocache. What can be wrong? Tried two servers.
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> -- 
> SIMON Alexandre
> 



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



[PHP] Encoding of PHP files

2007-06-22 Thread Guus Ellenkamp
What encoding should a PHP file itself have (so not it's output setting). 

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



[PHP] Encoding of PHP files

2007-06-22 Thread Guus Ellenkamp
What encoding should a PHP file itself have (so not it's output setting).

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



[PHP] php not working anymore in IIS

2007-07-29 Thread Guus Ellenkamp
After changing my php folder from e:\php to f:\php php does not work anymore 
in my webserver. I found out regsvr32 phpisapi.dll gives an error. I 
remember having a similar problem but am not sure what and how.

Anyone know how to fix? 

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