NEW Can set value for EHLO smtp command in MAIL_SMTP_USE_FROM_FOR_HELO
This commit is contained in:
parent
257fe444af
commit
77864f2c2c
@ -464,20 +464,26 @@ class SMTPs
|
|||||||
$host = 'tls://'.$host;
|
$host = 'tls://'.$host;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hosth = $host;
|
$hosth = $host; // so for example 'localhost' or 'smtp-relay.gmail.com'
|
||||||
|
|
||||||
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||||
// If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
|
if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||||
$hosth = $this->getFrom('addr');
|
// If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name
|
||||||
$hosth = preg_replace('/^.*</', '', $hosth);
|
$hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO;
|
||||||
$hosth = preg_replace('/>.*$/', '', $hosth);
|
} else {
|
||||||
$hosth = preg_replace('/.*@/', '', $hosth);
|
// If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from.
|
||||||
|
// So if the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
|
||||||
|
$hosth = $this->getFrom('addr');
|
||||||
|
$hosth = preg_replace('/^.*</', '', $hosth);
|
||||||
|
$hosth = preg_replace('/>.*$/', '', $hosth);
|
||||||
|
$hosth = preg_replace('/.*@/', '', $hosth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
|
if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
|
||||||
if ($usetls) {
|
if ($usetls) {
|
||||||
/*
|
/*
|
||||||
The following dialog illustrates how a client and server can start a TLS STARTTLS session
|
The following dialog illustrates how a client and server can start a TLS STARTTLS session:
|
||||||
S: <waits for connection on TCP port 25>
|
S: <waits for connection on TCP port 25>
|
||||||
C: <opens connection>
|
C: <opens connection>
|
||||||
S: 220 mail.imc.org SMTP service ready
|
S: 220 mail.imc.org SMTP service ready
|
||||||
@ -494,6 +500,39 @@ class SMTPs
|
|||||||
S: 250-server-domain.com
|
S: 250-server-domain.com
|
||||||
S: 250 AUTH LOGIN
|
S: 250 AUTH LOGIN
|
||||||
C: <continues by sending an SMTP command
|
C: <continues by sending an SMTP command
|
||||||
|
|
||||||
|
Another example here:
|
||||||
|
S: 220 smtp.server.com Simple Mail Transfer Service Ready
|
||||||
|
C: EHLO client.example.com
|
||||||
|
S: 250-smtp.server.com Hello client.example.com
|
||||||
|
S: 250-SIZE 1000000
|
||||||
|
S: 250-AUTH LOGIN PLAIN CRAM-MD5
|
||||||
|
S: 250-STARTTLS
|
||||||
|
S: 250 HELP
|
||||||
|
C: STARTTLS
|
||||||
|
S: 220 TLS go ahead
|
||||||
|
C: EHLO client.example.com *
|
||||||
|
S: 250-smtp.server.com Hello client.example.com
|
||||||
|
S: 250-SIZE 1000000
|
||||||
|
S: 250-AUTH LOGIN PLAIN CRAM-MD5
|
||||||
|
S: 250 HELP
|
||||||
|
C: AUTH LOGIN
|
||||||
|
S: 334 VXNlcm5hbWU6
|
||||||
|
C: adlxdkej
|
||||||
|
S: 334 UGFzc3dvcmQ6
|
||||||
|
C: lkujsefxlj
|
||||||
|
S: 235 2.7.0 Authentication successful
|
||||||
|
C: MAIL FROM:<mail@samlogic.com>
|
||||||
|
S: 250 OK
|
||||||
|
C: RCPT TO:<john@mail.com>
|
||||||
|
S: 250 OK
|
||||||
|
C: DATA
|
||||||
|
S: 354 Send message, end with a "." on a line by itself
|
||||||
|
C: <The message data (body text, subject, e-mail header, attachments etc) is sent>
|
||||||
|
S .
|
||||||
|
S: 250 OK, message accepted for delivery: queued as 12345
|
||||||
|
C: QUIT
|
||||||
|
S: 221 Bye
|
||||||
*/
|
*/
|
||||||
if (!$_retVal = $this->socket_send_str('STARTTLS', 220)) {
|
if (!$_retVal = $this->socket_send_str('STARTTLS', 220)) {
|
||||||
$this->_setErr(131, 'STARTTLS connection is not supported.');
|
$this->_setErr(131, 'STARTTLS connection is not supported.');
|
||||||
@ -517,10 +556,10 @@ class SMTPs
|
|||||||
$this->_setErr(132, 'STARTTLS connection failed.');
|
$this->_setErr(132, 'STARTTLS connection failed.');
|
||||||
return $_retVal;
|
return $_retVal;
|
||||||
}
|
}
|
||||||
// Most server servers expect a 2nd pass of EHLO after TLS is established to get another time
|
// Most servers expect a 2nd pass of EHLO after TLS is established to get another time
|
||||||
// the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
|
// the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
|
||||||
if (!$_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
|
if (! $_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
|
||||||
$this->_setErr(126, '"'.$hosth.'" does not support authenticated connections.');
|
$this->_setErr(126, '"'.$hosth.'" does not support authenticated connections. Error after sending EHLO '.$hosth);
|
||||||
return $_retVal;
|
return $_retVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -560,7 +599,7 @@ class SMTPs
|
|||||||
$this->_setErr(130, 'Invalid Authentication Credentials.');
|
$this->_setErr(130, 'Invalid Authentication Credentials.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_setErr(126, '"'.$host.'" does not support authenticated connections.');
|
$this->_setErr(126, '"'.$host.'" does not support authenticated connections. Error after sending EHLO '.$hosth);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_retVal;
|
return $_retVal;
|
||||||
@ -603,11 +642,17 @@ class SMTPs
|
|||||||
$hosth = $host;
|
$hosth = $host;
|
||||||
|
|
||||||
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||||
// If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
|
if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||||
$hosth = $this->getFrom('addr');
|
// If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name
|
||||||
$hosth = preg_replace('/^.*</', '', $hosth);
|
$hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO;
|
||||||
$hosth = preg_replace('/>.*$/', '', $hosth);
|
} else {
|
||||||
$hosth = preg_replace('/.*@/', '', $hosth);
|
// If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from.
|
||||||
|
// If the from to is 'aaa <bbb@ccc.com>', we will keep 'ccc.com'
|
||||||
|
$hosth = $this->getFrom('addr');
|
||||||
|
$hosth = preg_replace('/^.*</', '', $hosth);
|
||||||
|
$hosth = preg_replace('/>.*$/', '', $hosth);
|
||||||
|
$hosth = preg_replace('/.*@/', '', $hosth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_retVal = $this->socket_send_str('HELO '.$hosth, '250');
|
$_retVal = $this->socket_send_str('HELO '.$hosth, '250');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user