protected xclient variable and added tests
This commit is contained in:
parent
75991e3e46
commit
6384753f6e
|
|
@ -29,7 +29,9 @@ $mail->Host = 'mail.example.com';
|
|||
$mail->Port = 25;
|
||||
//Whether to use SMTP authentication
|
||||
$mail->SMTPAuth = false;
|
||||
$mail->SMTPXClient = ['LOGIN' => 'yourname@example.com'];
|
||||
$mail->setSMTPXclientAttribute('LOGIN', 'yourname@example.com');
|
||||
$mail->setSMTPXclientAttribute('ADDR', '10.10.10.10');
|
||||
$mail->setSMTPXclientAttribute('HELO', 'test.example.com');
|
||||
//Set who the message is to be sent from
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
//Set an alternative reply-to address
|
||||
|
|
@ -358,12 +358,11 @@ class PHPMailer
|
|||
public $AuthType = '';
|
||||
|
||||
/**
|
||||
* SMTP SMTPXClient command variables
|
||||
* Options are NAME | ADDR | PORT | PROTO | HELO | LOGIN | DESTADDR | DESTPORT
|
||||
* SMTP SMTPXClient command attibutes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $SMTPXClient = [];
|
||||
protected $SMTPXClient = [];
|
||||
|
||||
/**
|
||||
* An implementation of the PHPMailer OAuthTokenProvider interface.
|
||||
|
|
@ -2005,6 +2004,29 @@ class PHPMailer
|
|||
return $this->smtp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide SMTP XCLIENT attributes
|
||||
* Possible attributes are NAME, ADDR, PORT, PROTO, HELO, LOGIN, DESTADDR, DESTPORT
|
||||
*
|
||||
* @param string $name Attribute name
|
||||
* @param ?string $value Attribute value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setSMTPXclientAttribute($name, $value)
|
||||
{
|
||||
if (!in_array($name, ['NAME', 'ADDR', 'PORT', 'PROTO', 'HELO', 'LOGIN', 'DESTADDR', 'DESTPORT'])) {
|
||||
return false;
|
||||
}
|
||||
if (isset($this->SMTPXClient[$name]) && $value === null) {
|
||||
unset($this->SMTPXClient[$name]);
|
||||
} else if ($value !== null) {
|
||||
$this->SMTPXClient[$name] = $value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail via SMTP.
|
||||
* Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
|
||||
|
|
|
|||
|
|
@ -965,7 +965,7 @@ class SMTP
|
|||
|
||||
/**
|
||||
* Send SMTP XCLIENT command to server and check its return code.
|
||||
* Possible keys NAME | ADDR | PORT | PROTO | HELO | LOGIN | DESTADDR | DESTPORT
|
||||
* Possible keys NAME, ADDR, PORT, PROTO, HELO, LOGIN, DESTADDR, DESTPORT
|
||||
* @return bool True on success
|
||||
*/
|
||||
public function xclient(array $vars)
|
||||
|
|
|
|||
|
|
@ -1191,6 +1191,25 @@ EOT;
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SMTP Xclient options
|
||||
*/
|
||||
public function testSmtpXclient()
|
||||
{
|
||||
$this->Mail->isSMTP();
|
||||
$this->Mail->SMTPAuth = false;
|
||||
$this->Mail->setSMTPXclientAttribute('ADDR', '127.0.0.1');
|
||||
$this->Mail->setSMTPXclientAttribute('LOGIN', 'user@example.com');
|
||||
$this->assertFalse($this->Mail->setSMTPXclientAttribute('INVALID', 'value'));
|
||||
$this->Mail->Subject .= ': Testing XCLIENT';
|
||||
$this->buildBody();
|
||||
$this->Mail->clearAllRecipients();
|
||||
self::assertTrue($this->Mail->addAddress('a@example.com'), 'Addressing failed');
|
||||
$this->Mail->preSend();
|
||||
self::assertTrue($this->Mail->send(), 'send failed');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test SMTP host connections.
|
||||
* This test can take a long time, so run it last.
|
||||
|
|
|
|||
Loading…
Reference in New Issue