mirror of
https://github.com/PHPMailer/PHPMailer.git
synced 2024-09-20 01:52:15 +02:00
Use constants more consistently
This commit is contained in:
parent
ed901561d5
commit
8414097b86
@ -103,7 +103,7 @@ try {
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = 'user@example.com'; // SMTP username
|
||||
$mail->Password = 'secret'; // SMTP password
|
||||
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted
|
||||
$mail->Port = 587; // TCP port to connect to
|
||||
|
||||
//Recipients
|
||||
|
@ -32,8 +32,8 @@ $mail->Host = 'smtp.gmail.com';
|
||||
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
|
||||
$mail->Port = 587;
|
||||
|
||||
//Set the encryption system to use - ssl (deprecated) or tls
|
||||
$mail->SMTPSecure = 'tls';
|
||||
//Set the encryption mechanism to use - STARTTLS or SMTPS
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
|
||||
//Whether to use SMTP authentication
|
||||
$mail->SMTPAuth = true;
|
||||
|
@ -36,8 +36,8 @@ $mail->Host = 'smtp.gmail.com';
|
||||
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
|
||||
$mail->Port = 587;
|
||||
|
||||
//Set the encryption system to use - ssl (deprecated) or tls
|
||||
$mail->SMTPSecure = 'tls';
|
||||
//Set the encryption mechanism to use - STARTTLS or SMTPS
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
|
||||
//Whether to use SMTP authentication
|
||||
$mail->SMTPAuth = true;
|
||||
@ -88,7 +88,7 @@ $mail->Subject = 'PHPMailer GMail XOAUTH2 SMTP test';
|
||||
|
||||
//Read an HTML message body from an external file, convert referenced images to embedded,
|
||||
//convert HTML into a basic plain-text alternative body
|
||||
$mail->CharSet = 'utf-8';
|
||||
$mail->CharSet = PHPMailer::CHARSET_UTF8;
|
||||
$mail->msgHTML(file_get_contents('contentsutf8.html'), __DIR__);
|
||||
|
||||
//Replace the plain text body with one created manually
|
||||
|
@ -54,8 +54,8 @@ if (array_key_exists('to', $_POST)) {
|
||||
$mail = new PHPMailer;
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'localhost';
|
||||
$mail->Port = 2500;
|
||||
$mail->CharSet = 'utf-8';
|
||||
$mail->Port = 25;
|
||||
$mail->CharSet = PHPMailer::CHARSET_UTF8;
|
||||
//It's important not to use the submitter's address as the from address as it's forgery,
|
||||
//which will cause your messages to fail SPF checks.
|
||||
//Use an address in your own domain as the from address, put the submitter's address in a reply-to
|
||||
|
@ -30,8 +30,8 @@ $mail->Host = 'smtp.example.com';
|
||||
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
|
||||
$mail->Port = 587;
|
||||
|
||||
//Set the encryption system to use - ssl (deprecated) or tls
|
||||
$mail->SMTPSecure = 'tls';
|
||||
//Set the encryption mechanism to use - STARTTLS or SMTPS
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
|
||||
//Custom connection options
|
||||
//Note that these settings are INSECURE
|
||||
|
@ -273,7 +273,7 @@ class PHPMailer
|
||||
|
||||
/**
|
||||
* What kind of encryption to use on the SMTP connection.
|
||||
* Options: '', 'ssl' or 'tls'.
|
||||
* Options: '', static::ENCRYPTION_STARTTLS, or static::ENCRYPTION_SMTPS.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@ -1928,19 +1928,19 @@ class PHPMailer
|
||||
}
|
||||
$prefix = '';
|
||||
$secure = $this->SMTPSecure;
|
||||
$tls = ('tls' == $this->SMTPSecure);
|
||||
if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) {
|
||||
$tls = (static::ENCRYPTION_STARTTLS == $this->SMTPSecure);
|
||||
if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and static::ENCRYPTION_SMTPS == $this->SMTPSecure)) {
|
||||
$prefix = 'ssl://';
|
||||
$tls = false; // Can't have SSL and TLS at the same time
|
||||
$secure = 'ssl';
|
||||
$secure = static::ENCRYPTION_SMTPS;
|
||||
} elseif ('tls' == $hostinfo[2]) {
|
||||
$tls = true;
|
||||
// tls doesn't use a prefix
|
||||
$secure = 'tls';
|
||||
$secure = static::ENCRYPTION_STARTTLS;
|
||||
}
|
||||
//Do we need the OpenSSL extension?
|
||||
$sslext = defined('OPENSSL_ALGO_SHA256');
|
||||
if ('tls' === $secure or 'ssl' === $secure) {
|
||||
if (static::ENCRYPTION_STARTTLS === $secure or static::ENCRYPTION_SMTPS === $secure) {
|
||||
//Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
|
||||
if (!$sslext) {
|
||||
throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL);
|
||||
@ -4189,9 +4189,9 @@ class PHPMailer
|
||||
* You should avoid this function - it's more verbose, less efficient, more error-prone and
|
||||
* harder to debug than setting properties directly.
|
||||
* Usage Example:
|
||||
* `$mail->set('SMTPSecure', 'tls');`
|
||||
* `$mail->set('SMTPSecure', static::ENCRYPTION_STARTTLS);`
|
||||
* is the same as:
|
||||
* `$mail->SMTPSecure = 'tls';`.
|
||||
* `$mail->SMTPSecure = static::ENCRYPTION_STARTTLS;`.
|
||||
*
|
||||
* @param string $name The property name to set
|
||||
* @param mixed $value The value to set the property to
|
||||
|
@ -79,7 +79,7 @@ final class PHPMailerTest extends TestCase
|
||||
$this->Mail->Debugoutput = ['PHPMailer\Test\DebugLogTestListener', 'debugLog'];
|
||||
$this->Mail->Priority = 3;
|
||||
$this->Mail->Encoding = '8bit';
|
||||
$this->Mail->CharSet = 'iso-8859-1';
|
||||
$this->Mail->CharSet = PHPMailer::CHARSET_ISO88591;
|
||||
if (array_key_exists('mail_from', $_REQUEST)) {
|
||||
$this->Mail->From = $_REQUEST['mail_from'];
|
||||
} else {
|
||||
@ -221,10 +221,10 @@ final class PHPMailerTest extends TestCase
|
||||
if (3 != $this->Mail->Priority) {
|
||||
$this->addChange('Priority', $this->Mail->Priority);
|
||||
}
|
||||
if ('8bit' != $this->Mail->Encoding) {
|
||||
if (PHPMailer::ENCODING_8BIT != $this->Mail->Encoding) {
|
||||
$this->addChange('Encoding', $this->Mail->Encoding);
|
||||
}
|
||||
if ('iso-8859-1' != $this->Mail->CharSet) {
|
||||
if (PHPMailer::CHARSET_ISO88591 != $this->Mail->CharSet) {
|
||||
$this->addChange('CharSet', $this->Mail->CharSet);
|
||||
}
|
||||
if ('' != $this->Mail->Sender) {
|
||||
@ -312,7 +312,7 @@ final class PHPMailerTest extends TestCase
|
||||
$this->Mail->Host = 'hostname';
|
||||
$this->Mail->Port = 587;
|
||||
$this->Mail->SMTPAuth = true;
|
||||
$this->Mail->SMTPSecure = 'tls';
|
||||
$this->Mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$this->Mail->AuthType = 'CRAM-MD5';
|
||||
$this->Mail->Username = 'username';
|
||||
$this->Mail->Password = 'password';
|
||||
@ -1023,7 +1023,7 @@ EOT;
|
||||
{
|
||||
$this->Mail->isHTML(true);
|
||||
$this->Mail->Subject .= ': ISO-8859-1 HTML';
|
||||
$this->Mail->CharSet = 'iso-8859-1';
|
||||
$this->Mail->CharSet = PHPMailer::CHARSET_ISO88591;
|
||||
|
||||
//This file is in ISO-8859-1 charset
|
||||
//Needs to be external because this file is in UTF-8
|
||||
@ -1135,7 +1135,7 @@ EOT;
|
||||
public function testMsgHTML()
|
||||
{
|
||||
$message = file_get_contents(realpath($this->INCLUDE_DIR . '/examples/contentsutf8.html'));
|
||||
$this->Mail->CharSet = 'utf-8';
|
||||
$this->Mail->CharSet = PHPMailer::CHARSET_UTF8;
|
||||
$this->Mail->Body = '';
|
||||
$this->Mail->AltBody = '';
|
||||
//Uses internal HTML to text conversion
|
||||
@ -1795,7 +1795,7 @@ EOT;
|
||||
*/
|
||||
public function testEncodings()
|
||||
{
|
||||
$this->Mail->CharSet = 'iso-8859-1';
|
||||
$this->Mail->CharSet = PHPMailer::CHARSET_ISO88591;
|
||||
$this->assertEquals(
|
||||
'=A1Hola!_Se=F1or!',
|
||||
$this->Mail->encodeQ("\xa1Hola! Se\xf1or!", 'text'),
|
||||
@ -2432,7 +2432,7 @@ EOT;
|
||||
*/
|
||||
public function testConfirmReadingTo()
|
||||
{
|
||||
$this->Mail->CharSet = 'utf-8';
|
||||
$this->Mail->CharSet = PHPMailer::CHARSET_UTF8;
|
||||
$this->buildBody();
|
||||
|
||||
$this->Mail->ConfirmReadingTo = 'test@example..com'; //Invalid address
|
||||
@ -2522,7 +2522,7 @@ EOT;
|
||||
$this->Mail->clearAllRecipients();
|
||||
$this->Mail->clearReplyTos();
|
||||
|
||||
$this->Mail->CharSet = 'utf-8';
|
||||
$this->Mail->CharSet = PHPMailer::CHARSET_UTF8;
|
||||
|
||||
$this->assertTrue($this->Mail->addAddress('test@françois.ch'));
|
||||
$this->assertFalse($this->Mail->addAddress('test@françois.ch'));
|
||||
|
Loading…
Reference in New Issue
Block a user