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;
|
||||
}
|
||||
|
||||
$hosth = $host;
|
||||
$hosth = $host; // so for example 'localhost' or 'smtp-relay.gmail.com'
|
||||
|
||||
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||
// 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 (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||
// If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name
|
||||
$hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO;
|
||||
} else {
|
||||
// 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 ($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>
|
||||
C: <opens connection>
|
||||
S: 220 mail.imc.org SMTP service ready
|
||||
@ -494,6 +500,39 @@ class SMTPs
|
||||
S: 250-server-domain.com
|
||||
S: 250 AUTH LOGIN
|
||||
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)) {
|
||||
$this->_setErr(131, 'STARTTLS connection is not supported.');
|
||||
@ -517,10 +556,10 @@ class SMTPs
|
||||
$this->_setErr(132, 'STARTTLS connection failed.');
|
||||
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.
|
||||
if (!$_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
|
||||
$this->_setErr(126, '"'.$hosth.'" does not support authenticated connections.');
|
||||
if (! $_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
|
||||
$this->_setErr(126, '"'.$hosth.'" does not support authenticated connections. Error after sending EHLO '.$hosth);
|
||||
return $_retVal;
|
||||
}
|
||||
}
|
||||
@ -560,7 +599,7 @@ class SMTPs
|
||||
$this->_setErr(130, 'Invalid Authentication Credentials.');
|
||||
}
|
||||
} 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;
|
||||
@ -603,11 +642,17 @@ class SMTPs
|
||||
$hosth = $host;
|
||||
|
||||
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||
// 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 (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
|
||||
// If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name
|
||||
$hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO;
|
||||
} else {
|
||||
// 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');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user