472,139 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

setRequestHeader method doesn't work with POP3

62
Hello
Refer to the thread that i have posted before: http://www.thescripts.com/forum/thread755824.html

On that time i got problem about encode ajax to send email...everything worked find after i use setRequestHeader and encodeURIComponent...but
then i test it with POP3 mail everything is not encoded...why ? And is it has some way to fix this ?
thank you so much
Paitoon
Jan 23 '08 #1
10 1855
acoder
16,027 Expert Mod 8TB
Show your code. What isn't encoded properly?
Jan 24 '08 #2
paitoon
62
this is some part in my AJAX:
Expand|Select|Wrap|Line Numbers
  1.  
  2.   var params = "sender=" + encodeURIComponent(document.iform.sender.value)+
  3.     "&email=" + encodeURIComponent(document.iform.email.value)+
  4.     "&subject=" + encodeURIComponent(document.iform.subject.value)+
  5.     "&text=" + encodeURIComponent(document.iform.text.value);
  6.  
  7.  
  8. xmlHttp=GetXmlHttpObject()  
  9. var url="process.php"
  10. xmlHttp.onreadystatechange=myResult; 
  11. open("POST",url,true)
  12. xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  13. xmlHttp.send(params)
  14.  
  15.  
  16.  
  17.  
AND THIS IS MY PHP PAGE TO SEND MAIL
[php]<?php
$recipient = 'geisha@hotmail.com';
$params = $_POST['params'];
$subject = $_POST['subject'];
$from = $_POST['sender']; // variable SENDER from ajax
$email = $_POST['email'];
$text= $_POST['text'];
$ip = $_SERVER['REMOTE_ADDR'];

$msg = "From: $from\n Email: $email \n IP Adrress :$ip \n\n Message: $text";
mail($recipient, $subject, $msg);

?>[/php]

Everything worked good in hotmail, gmail, yahoo But not in web-mail or POP3 program.


Please tell me what should i do.
thanks a lot
Alex
Jan 24 '08 #3
acoder
16,027 Expert Mod 8TB
Can you send to a POP3 account without using Ajax?
Jan 24 '08 #4
paitoon
62
Actually yes, But I just want to know if it's possible or what is this problem etc..
Because it's work fine on normail mail but why it doesn't work with web-mail or pop3 ?
actually i was happy after i made everything hard finish and i use the time for this for a month (so hard) but a few days ago i opened it in web-mail and POP3 program it's disappoint me in the end my problem is not really gone...:-/

I did not expect that my site should be 100 % perfect but....i just wonder why ? I also tried to send email from my hotmail to that web-mail in thai language...everything is encoded and it's great work without going to VIEW and choose ENCODE on windows.

This is why i still stress and wonder how hotmail and other normal mail do, and why couldn't I.


But thank you so much at least U lead the way :-)
Alex
Jan 24 '08 #5
acoder
16,027 Expert Mod 8TB
So the text of the email is in Thai?

Have you set the correct headers/charsets? If, in PHP, you send email to the POP3/web-mail account using the mail function with Thai characters, does it send/receive OK?
Jan 24 '08 #6
paitoon
62
eventually i got it,
1. the reason that email not encoded in POP3 program that because i have to set the default encoded in the program to be UTF-8 (before it's western europe)
2. the reason that it's not encoded in web-mail (they use squrrel mail) because they just told me that they are not support asian langage.

Well, i got stress but got much more experiance. And i hope it will be the useful for other people also.

But i still wonder why gmail can do? I send message in Thai language to that POP3 and it's encoded correctly without setting anything.?Because gmail also use ajax.....

Thanks alot for all your help
Alex
Jan 24 '08 #7
acoder
16,027 Expert Mod 8TB
But i still wonder why gmail can do? I send message in Thai language to that POP3 and it's encoded correctly without setting anything.?Because gmail also use ajax...
You can set the header using setRequestHeader, so it must be set to UTF-8.
Jan 25 '08 #8
paitoon
62
So you means in javascript ?'

xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

i did it but it make email not work.

xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-uutf-8');
Jan 25 '08 #9
paitoon
62
But it ok....i give up
thank you so much
Alex
Jan 25 '08 #10
acoder
16,027 Expert Mod 8TB
I meant something like:
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; Charset=utf-8");
Jan 28 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Daniel Albisser | last post: by
1 post views Thread by Lev Altshuler | last post: by
reply views Thread by Eric McDaniel | last post: by
4 posts views Thread by Ron Vecchi | last post: by
2 posts views Thread by Mike Brearley | last post: by
reply views Thread by leo001 | last post: by

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.