Dexter
Dexter

Reputation: 3122

PEAR Mail, SMTP Sessions for Newsletters?

when sending newsletters through a SMTP server using PEAR's Mail package, is there any way to specify some kind of "connection reuse" so that the PHP script won't have to create a new socket to the SMTP server for each individual mail?

That is of course without putting the adress of each recipient in only one e-mail, so that the indvidual recipient's won't see each others adresses.

Or doesn't SMTP allow for this?

Upvotes: 0

Views: 403

Answers (3)

dennis
dennis

Reputation: 630

What you should do is set the 'persist' param. And then only use the factory method once - then you ensure that it is the same socket that is used.

something like this:

static $mail;
if (!is_object($mail)) {
    $mail = Mail::factory($options['mail_method'], $params);
}
$res = $mail->send($to, $mime_headers, $body);

If you call the mail::factory every time then a new socket will be created. In the above way you only create one socket.

Upvotes: 0

Dexter
Dexter

Reputation: 3122

PEAR Mail seems to be a hopeless case, but Zend's framework has addressed the issue and keeps the SMTP socket open for as long as the script runs (and the object exists): http://framework.zend.com/manual/en/zend.mail.multiple-emails.html

Upvotes: 1

ab_dev86
ab_dev86

Reputation: 1982

Well I think the best solution is to put each destinee in black carbon. This guarantees that who receives the mail does not see other mail addresses and is a better solution than sending a mail for each destinee

This is feasible with php pear Mail package.

Upvotes: 1

Related Questions