setRequestHeader method doesn't work with POP3

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paitoon
    New Member
    • Aug 2007
    • 62

    #1

    setRequestHeader method doesn't work with POP3

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

    On that time i got problem about encode ajax to send email...everyth ing worked find after i use setRequestHeade r and encodeURICompon ent...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
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Show your code. What isn't encoded properly?

    Comment

    • paitoon
      New Member
      • Aug 2007
      • 62

      #3
      this is some part in my AJAX:
      [code=javascript]

      var params = "sender=" + encodeURICompon ent(document.if orm.sender.valu e)+
      "&email=" + encodeURICompon ent(document.if orm.email.value )+
      "&subject=" + encodeURICompon ent(document.if orm.subject.val ue)+
      "&text=" + encodeURICompon ent(document.if orm.text.value) ;


      xmlHttp=GetXmlH ttpObject()
      var url="process.ph p"
      xmlHttp.onready statechange=myR esult;
      open("POST",url ,true)
      xmlHttp.setRequ estHeader('Cont ent-Type', 'application/x-www-form-urlencoded');
      xmlHttp.send(pa rams)



      [/code]

      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
      Last edited by acoder; Jan 24 '08, 11:05 AM. Reason: fixed code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Can you send to a POP3 account without using Ajax?

        Comment

        • paitoon
          New Member
          • Aug 2007
          • 62

          #5
          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...ever ything 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

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            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?

            Comment

            • paitoon
              New Member
              • Aug 2007
              • 62

              #7
              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.?Becau se gmail also use ajax.....

              Thanks alot for all your help
              Alex

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by paitoon
                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.?Becau se gmail also use ajax...
                You can set the header using setRequestHeade r, so it must be set to UTF-8.

                Comment

                • paitoon
                  New Member
                  • Aug 2007
                  • 62

                  #9
                  So you means in javascript ?'

                  xmlHttp.setRequ estHeader('Cont ent-Type', 'application/x-www-form-urlencoded');

                  i did it but it make email not work.

                  xmlHttp.setRequ estHeader('Cont ent-Type', 'application/x-www-form-uutf-8');

                  Comment

                  • paitoon
                    New Member
                    • Aug 2007
                    • 62

                    #10
                    But it ok....i give up
                    thank you so much
                    Alex

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      I meant something like:
                      [code=javascript]xmlHttp.setRequ estHeader("Cont ent-Type", "applicatio n/x-www-form-urlencoded; Charset=utf-8");[/code]

                      Comment

                      Working...