Update SMTP subclass example
This commit is contained in:
parent
ee4090bd62
commit
b11a4512de
|
|
@ -4,9 +4,8 @@
|
||||||
* SMTP low memory example.
|
* SMTP low memory example.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
use PHPMailer\PHPMailer\SMTP;
|
||||||
require '../vendor/autoload.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class demonstrates sending an already-built RFC822 message via SMTP
|
* This class demonstrates sending an already-built RFC822 message via SMTP
|
||||||
|
|
@ -31,8 +30,10 @@ class SMTPLowMemory extends SMTP
|
||||||
* According to rfc821 we should not send more than 1000 characters on a single line (including the LE)
|
* According to rfc821 we should not send more than 1000 characters on a single line (including the LE)
|
||||||
* so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
|
* so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
|
||||||
* smaller lines to fit within the limit.
|
* smaller lines to fit within the limit.
|
||||||
* We will also look for lines that start with a '.' and prepend an additional '.'.
|
* We will also look for lines that start with a '.' and prepend an additional '.' (which does not count
|
||||||
* NOTE: this does not count towards line-length limit.
|
* towards the line-length limit), in order to implement the "dot stuffing" required by RFC5321 sections:
|
||||||
|
* https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.2
|
||||||
|
* https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1.6.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Normalize line breaks
|
//Normalize line breaks
|
||||||
|
|
@ -110,22 +111,7 @@ class SMTPLowMemory extends SMTP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//To make PHPMailer use our custom SMTP class, we need to give it an instance
|
||||||
* We need to use a PHPMailer subclass to make it use our SMTP implementation.
|
$mail = new PHPMailer(true);
|
||||||
* @package PHPMailer\PHPMailer
|
$mail->setSMTPInstance(new SMTPLowMemory());
|
||||||
*/
|
//Now carry on as normal
|
||||||
class PHPMailerLowMemory extends PHPMailer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Patch in the new SMTP class.
|
|
||||||
* @return SMTP
|
|
||||||
*/
|
|
||||||
public function getSMTPInstance()
|
|
||||||
{
|
|
||||||
if (!is_object($this->smtp)) {
|
|
||||||
$this->smtp = new SMTPLowMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->smtp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue