I have a PHPMailer 5.2.16 on a server using Exim 4.87 which also has a TLS certificate for secured connections.
My PHP is thus:
class MailerSMTP extends PHPMailer {
/***
* Mailer for authenticated SMTP emails using account mail system
***/
public function __construct(){
$this->AddReplyTo('...', '...');
$this->setFrom('...', '...');
$this->Host = "hostname.co.uk";
$this->isSMTP();
$this->Timeout = 20;
$this->SMTPAuth = true;
$this->SMTPSecure = "tls";
$this->Port = "587";
$this->Username = 'emailuser';
$this->Password = 'emailpass';
}
}
And this is obviously called on the script and populated with reciever and message, etc.
However the SMTPSecure
aspect adds about 2 seconds (or sometimes a bit more) on to the time taken to send the message. Currently this delay is on a single message sending, and I would hope (I think I read somewhere) that the SMTP secure would only need to be called once to send X number of messages to X number of recipients.
- While I accept this delay might be unavoidable to some extent, I would like some advice on to how to improve the efficiency of secured SMTP via this method?
Bonus Question:
- Am I correct in thinking that this delay would only occur once when this class is instantiated, regardless of the number of emails sent through it?
I would imagine I can do something like this:
$sender = new MailerSMTP();
$sender->subject ="hello";
$sender->Body = "message";
foreach($receiver as $row){
$sender->addAddress($row['email']);
$sender->send();
$sender->clearAddresses();
}
Would this send all emails with only a 2 second SMTPSecure
delay?