简体   繁体   中英

SMTP connection using PHP errors

There is something wrong with:

$s = fsockopen($mailserver, 25);
echo '1 > '.fgets($s);
fwrite($s, 'HELO');
echo '2 > '.fgets($s);
fclose($s);

Output:

1 > 220 mail.sogetthis.com ESMTP Postfix 2 >

The 220 code means the SMTP server is ready to accept commands. You're issuing a HELO command, and the server should respond with a 250 if your last command was successful, which it is not. Try adding the mailserver domain you're connecting to after your HELO command.

fwrite($s, "HELO domain.com\r\n");

In addition, you should include \\r\\n control characters after all your commands. Notice the double-quotes around the command. That's required to use \\r\\n in this case because double-quotes evaluate variables and control characters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM