| | |
| | | * |
| | | */ |
| | | private function detectHelo() { |
| | | if(isset($_SERVER['HTTP_HOST'])) $this->smtp_helo = $_SERVER['HTTP_HOST']; |
| | | if(isset($_SERVER['HTTP_HOST'])) $this->smtp_helo = (strpos($_SERVER['HTTP_HOST'], ':') !== false ? substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')) : $_SERVER['HTTP_HOST']); |
| | | elseif(isset($_SERVER['SERVER_NAME'])) $this->smtp_helo = $_SERVER['SERVER_NAME']; |
| | | else $this->smtp_helo = php_uname('n'); |
| | | if($this->smtp_helo == '') $this->smtp_helo = 'localhost'; |
| | |
| | | $response = fgets($this->_smtp_conn, 515); |
| | | if(empty($this->_smtp_conn)) return false; |
| | | |
| | | //Say Hello to SMTP |
| | | if($this->smtp_helo == '') $this->detectHelo(); |
| | | fputs($this->_smtp_conn, 'HELO ' . $this->smtp_helo . $this->_crlf); |
| | | $response = fgets($this->_smtp_conn, 515); |
| | | |
| | | // ENCRYPTED? |
| | | if($this->smtp_crypt == 'tls') { |
| | | fputs($this->_smtp_conn, 'STARTTLS' . $this->_crlf); |
| | | fgets($this->_smtp_conn, 515); |
| | | stream_socket_enable_crypto($this->_smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); |
| | | } |
| | | |
| | | //Say Hello to SMTP |
| | | if($this->smtp_helo == '') $this->detectHelo(); |
| | | fputs($this->_smtp_conn, 'HELO ' . $this->smtp_helo . $this->_crlf); |
| | | $response = fgets($this->_smtp_conn, 515); |
| | | |
| | | //AUTH LOGIN |
| | | fputs($this->_smtp_conn, 'AUTH LOGIN' . $this->_crlf); |
| | |
| | | |
| | | $mail_content = 'Subject: ' . $enc_subject . $this->_crlf; |
| | | $mail_content .= 'To: ' . $this->getHeader('To') . $this->_crlf; |
| | | if($this->getHeader('Bcc') != '') $mail_content .= 'Bcc: ' . $this->_encodeHeader($this->getHeader('Bcc'), $this->mail_charset) . $this->_crlf; |
| | | if($this->getHeader('Cc') != '') $mail_content .= 'Cc: ' . $this->_encodeHeader($this->getHeader('Cc'), $this->mail_charset) . $this->_crlf; |
| | | $mail_content .= implode($this->_crlf, $headers) . $this->_crlf . ($this->_is_signed == false ? $this->_crlf : '') . $this->body; |
| | | |