Wrote a module for sending emails via gmail to SMTP. Half a year worked fine, there were no problems. That that has ceased to work, returns an error 501
ΠΡΠΈΠ±ΠΊΠ°: 5.5.4 HELO/EHLO argument ssl://smtp.gmail.com invalid, closing connection. e25sm23107227wmi.21 - gsmtp Π²ΠΌΠ΅ΡΡΠΎ 250 62
Tell me, what could happen that stopped all work?
More: A piece of text to send:
$sendMail = new sendMail("******@gmail.com", "******", 465, "ssl://smtp.gmail.com", "utf-8", "Error Reporting"); $sendMail->From('Error Reporting'); $sendMail->To('******@gmail.com'); $sendMail->Subject('Error Reporting'); $message = 'test test test';
send class itself:
<?php class sendMail{ private $username = false; private $password = false; private $port = false; private $host = false; private $charset = false; private $from = false; private $debug = false; private $_from = ''; private $_to = ''; private $_subject = ''; private $_send = ''; private $_message = ''; public function __construct($username, $password, $port, $host, $charset, $from) { $this->username = $username; $this->password = $password; $this->port = $port; $this->host = $host; $this->charset = $charset; $this->from = $from; $this->debug = true; } public function From($name){ $this->_from = "From: " . '=?utf-8?B?'.base64_encode($name).'?=' . " <" . $this->username . ">"; } public function To($email){ $this->_to = $email; } public function Subject($subject){ $this->_subject = $subject; } public function Message($message){ $this->_message = $message; } public function smtpmail(){ $this->_send .= "Date: ".date("D, d MYH:i:s") . " UT\r\n"; $this->_send .= "Subject: =?" . $this->charset .'?B?' . base64_encode($this->_subject) . "=?=\r\n"; $this->_send .= 'Content-type: text/html; charset="' . $this->charset .'"' . "\r\n"; $this->_send .= $this->_from."\r\n"; $this->_send .= "To: '" . $this->_to . "'<" . $this->_to . ">"."\r\n"; $this->_send .= "X-Priority: 3\r\n\r\n"; $this->_send .= $this->_message."\r\n"; if( !$socket = fsockopen($this->host, $this->port, $errno, $errstr, 30) ) { if ($this->debug) echo $errno."<br>".$errstr; return false; } if (!$this->server_parse($socket, "220", __LINE__)) return false; fputs($socket, "EHLO " . $this->host . "\r\n"); if (!$this->server_parse($socket, "250", __LINE__)) { if ($this->debug) echo '<p>ΠΠ΅ ΠΌΠΎΠ³Ρ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ HELO!</p>'; fclose($socket); return false; } fputs($socket, "AUTH LOGIN\r\n"); if (!$this->server_parse($socket, "334", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠ΅ ΠΌΠΎΠ³Ρ Π½Π°ΠΉΡΠΈ ΠΎΡΠ²Π΅Ρ Π½Π° Π·Π°ΠΏΡΠΎΡ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈ.</p></center>'; fclose($socket); return false; } fputs($socket, base64_encode($this->username) . "\r\n"); if (!$this->server_parse($socket, "334", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠΎΠ³ΠΈΠ½ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ Π½Π΅ Π±ΡΠ» ΠΏΡΠΈΠ½ΡΡ ΡΠ΅ΡΠ²Π΅ΡΠΎΠΌ!</p></center>'; fclose($socket); return false; } fputs($socket, base64_encode($this->password) . "\r\n"); if (!$this->server_parse($socket, "235", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠ°ΡΠΎΠ»Ρ Π½Π΅ Π±ΡΠ» ΠΏΡΠΈΠ½ΡΡ ΡΠ΅ΡΠ²Π΅ΡΠΎΠΌ ΠΊΠ°ΠΊ Π²Π΅ΡΠ½ΡΠΉ! ΠΡΠΈΠ±ΠΊΠ° Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ!</p></center>'; fclose($socket); return false; } fputs($socket, "MAIL FROM: <".$this->username.">\r\n"); if (!$this->server_parse($socket, "250", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠ΅ ΠΌΠΎΠ³Ρ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ ΠΊΠΎΠΌΠΌΠ°Π½Π΄Ρ MAIL FROM: </p></center>'; fclose($socket); return false; } fputs($socket, "RCPT TO: <" . $this->_to . ">\r\n"); if (!$this->server_parse($socket, "250", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠ΅ ΠΌΠΎΠ³Ρ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ ΠΊΠΎΠΌΠΌΠ°Π½Π΄Ρ RCPT TO: </p></center>'; fclose($socket); return false; } fputs($socket, "DATA\r\n"); if (!$this->server_parse($socket, "354", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠ΅ ΠΌΠΎΠ³Ρ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ ΠΊΠΎΠΌΠΌΠ°Π½Π΄Ρ DATA</p></center>'; fclose($socket); return false; } fputs($socket, $this->_send ."\r\n.\r\n"); if (!$this->server_parse($socket, "250", __LINE__)) { if ($this->debug) echo '<center><p>ΠΠ΅ ΡΠΌΠΎΠ³ ΠΎΡΠΏΡΠ°Π²ΠΈΡΡ ΡΠ΅Π»ΠΎ ΠΏΠΈΡΡΠΌΠ°. ΠΠΈΡΡΠΌΠΎ Π½Π΅ Π±ΡΠ»ΠΎ ΠΎΡΠΏΡΠ°Π²Π»Π΅Π½Π½ΠΎ!</p></center>'; fclose($socket); return false; } fputs($socket, "QUIT\r\n"); fclose($socket); return TRUE; } private function server_parse($socket, $response, $line = __LINE__) { while (@substr($server_response, 3, 1) != ' ') { if (!($server_response = fgets($socket, 256))) { if ($this->debug) echo "<p>Problems sending mail!</p>$response<br>$line<br>"; return false; } } if (substr($server_response, 0, 3) != $response) { if ($this->debug) echo "<p>Problems sending mail!</p>$server_response Π²ΠΌΠ΅ΡΡΠΎ $response<br>$line<br>"; return false; } return true; } }