[PHP] [QUESTION] MAIL: Send a NOOP instead of DATA
I wrote a class to send mail by remote mail server. But it was failed. So I captured the network packets by tcpdump, and found that there is a strange packet NOOP was sent. But in the source code I mean to send command DATA. I don't know why a NOOP packet was sent instead. Here is my php source code and the attachment is tcpdump file. --- ?php /** * sendmail class */ class sendmail { var $lastmessage; //last reply var $lastact; //last action var $welcome; //welcome info var $smtp; //smtp server var $port; //smtp port var $fp;//socket handler var $user; //smtp user account var $pass; //smtp user passwd /** * Constructor */ function sendmail($welcome) { global $config; $this-smtp=$config['smtp_svr']; if(empty($welcome)){ $this-welcome=gethostbyaddr($_SERVER['REMOTE_ADDR']); }else{ $this-welcome=$welcome; } $this-lastmessage=; $this-lastact=; $this-port=$config['smtp_port']; $this-user = base64_encode($config['smtp_user']); $this-pass = base64_encode($config['smtp_pass']); } /** * Exe command such as HELO, MAIL FROM, RCPT TO, QUIT, DATA * $code: reply code */ function do_command($command, $code) { $this-lastact=$command; fputs ( $this-fp, $this-lastact ); $this-lastmessage = fgets ( $this-fp, 512 ); if(!ereg(^$code, $this-lastmessage)) { return false; } else { return true; } } /** * Send mail * $to: the mail address of receiver * $subject:the subject of mail * $message:mail content * return: true -- successful * false -- fail */ function send( $to,$subject,$message) { global $config; $from=$config['smtp_from']; /* Connect to server. */ $this-lastact=connect; $this-show_debug(Connect to SMTP server : .$this-smtp,out); $this-fp = fsockopen ( $this-smtp, $this-port ); if ( $this-fp ) { set_socket_blocking( $this-fp, true ); $this-lastmessage=fgets($this-fp,512); /* reply 220 means connect sucessfully */ if (! ereg ( ^220, $this-lastmessage ) ) { return false; } else { $this-lastact=HELO . $this-welcome . \n; if(!$this-do_command($this-lastact, 250)){ fclose($this-fp); return false; } $this-lastact=AUTH LOGIN\r\n; if(!$this-do_command($this-lastact, 334)){ fclose($this-fp); return false; } $this-lastact=$this-user.\r\n; if(!$this-do_command($this-lastact, 334)){ fclose($this-fp); return false; } $this-lastact=$this-pass.\r\n; if(!$this-do_command($this-lastact, 235)){ fclose($this-fp); return false; } $this-lastact=MAIL FROM: $from . \n; if(!$this-do_command($this-lastact, 250)) { fclose($this-fp); return false; } $this-lastact=RCPT TO: $to . \n; if(!$this-do_command($this-lastact, 250)) { fclose($this-fp); return false; } /* Send data, I send a command DATA, but tcpdump capture a NOOP packet */ $this-lastact=DATA\n; if(!$this-do_command($this-lastact, 354)) {
Re: [PHP] [QUESTION] MAIL: Send a NOOP instead of DATA
Wang Chen said the following on 2008-1-16 11:38: I wrote a class to send mail by remote mail server. But it was failed. So I captured the network packets by tcpdump, and found that there is a strange packet NOOP was sent. But in the source code I mean to send command DATA. I don't know why a NOOP packet was sent instead. Here is my php source code and the attachment is tcpdump file. Seems that php-general maillist server can not accept attachment. I have to describe the tcpdump capture information here. snip snd:HELLO rcv:250 snd:AUTH LOGIN rcv:334 snip/* all ok */ snd:RCPT TO: [EMAIL PROTECTED] rcv:250 OK /* 30 second wait...? it's odd */ snd:NOOP/* it should be DATA, why NOOP? */ rcv:250 OK snip I use outlook to sent a same mail and captured right packets. snip snd:HELLO rcv:250 snd:AUTH LOGIN rcv:334 snip snd:RCPT TO: [EMAIL PROTECTED] rcv:250 OK snd:DATA rcv:354 Start mail input snd:Message body rcv:250 OK snip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [QUESTION] MAIL: Send a NOOP instead of DATA
Manuel Lemos said the following on 2008-1-16 11:55: Maybe you are accessing a SMTP server with a grey listing or anti-spam/anti-virus frontend that sits on the front of the actual SMTP server and only passes information to the backend server when it is ready. It is possible that your message is malformed and the frontend server is expecting something that you are not sending correctly. Meanwhile the frontend server sends NOOP commands to the backend server to keep the connection opened. But it's strange that php should send a DATA command out, but tcpdump didn't capture this packet. :( You may want to try this SMTP class that is known to work correctly according to the mail standards. See if you can send the message properly. If so, the theory above is likely to be the case. http://www.phpclasses.org/smtpclass If you need authentication, you also need this: http://www.phpclasses.org/sasl Thanks Manuel, I will try this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [QUESTION] MAIL: Send a NOOP instead of DATA
Manuel Lemos said the following on 2008-1-16 13:14: But it's strange that php should send a DATA command out, but tcpdump didn't capture this packet. :( I don't know why you are using tcpdump, but maybe you are only capturing a network interface that is not the one that your code used to connect to the SMTP server. It seems to me that is something is altering the data you are sending for some reason. I suggest that you ask your system administrator. For debugging my code, I use tcpdump to capture packets and compare the difference between outlook's packets and php's packets. By the way, i only have one NIC. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [QUESTION] MAIL: Send a NOOP instead of DATA
mike said the following on 2008-1-16 12:11: Why not look at phpmailer? Probably more robust than some random classes. http://phpmailer.codeworxtech.com/ Thanks Mike. I will try both and tell you guys I like which one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pass value to next page
Hi , Newbie question, I have a form, form acttion=search.php3 method=post input . input... ... /form The search.php3 goes to query mysql database to see if the infomation is new or existed, if new, will promt two radio buttons ( Yes or No) to confirm if you like to enter the info inot DB .The form will action=result.php My question is how we can passwd the values which are entered in first page to result.php page. Thank you for your help
Re: [PHP] pass value to next page
Thanks much, y'all. Forgive to my typo on the original email. On 11/7/06, Jochem Maas [EMAIL PROTECTED] wrote: Wang Chen wrote: Hi , Newbie question, I have a form, form acttion=search.php3 method=post input . input... ... /form The search.php3 goes to query mysql database to see if the infomation is .php3 extension is, I would say, discouraged. just use .php new or existed, if new, will promt two radio buttons ( Yes or No) to confirm if you like to enter the info inot DB .The form will action=result.php 2 options: 1. php solution, put the data in $_SESSION and retrieve it again when you have the 'insert' confirmation - (search the manual for session usage) 2. html solution, in the second form put the inputs from the first form, set all their type attributes to hidden and set the value accodingly: input type=hidden value=?php echo $data['foo']; ? name=foo / My question is how we can passwd the values which are entered in first page looks like you mean pass not passwd :-) to result.php page. Thank you for your help
[PHP] Add buttons on the fly
I would like to add two buttons on a page form infomation confirmation, however, the html code in php nest can not be known by browser if I put form xxx input xx /form into there. Besically, there is a mail form to enter iterm infomaiton, if it exist before, prompt its iterm id., if it is new, query a next available inerm id for it, then, show a page to ask such as, do you accept this id?, two buttons below this question, yes and no. Is there any fountion in php which can make it? Thanks.