VERP support
Moderators: Chris Corbyn, General Moderators
-
gmorehoudh
- Forum Commoner
- Posts: 50
- Joined: Tue Mar 04, 2008 1:49 pm
VERP support
What is the status of VERP support in Swift Mailer?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: VERP support
Coming in v4.
-
gmorehoudh
- Forum Commoner
- Posts: 50
- Joined: Tue Mar 04, 2008 1:49 pm
Re: VERP support
Any update when that'll be released? I'm starting a project for work that needs VERP and right now it's either Swift or the beta, "inadvisable for production" PHP5 version of PHPMailer.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: VERP support
Sorry, no ETA on that, it's being held up by things such as documentation and a few business-related issues. A ballpark date is April. There are a lot of changes coming (including to the website) and it has to be right first time.
-
gmorehoudh
- Forum Commoner
- Posts: 50
- Joined: Tue Mar 04, 2008 1:49 pm
Re: VERP support
Okay. Is it possible to simply set the 'sender' header manually? This appears to be how VERP is done with PHP Mailer unless you're running Postfix, in which case it can be automated.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: VERP support
Code: Select all
$message->headers->set('Sender', $something);-
gmorehoudh
- Forum Commoner
- Posts: 50
- Joined: Tue Mar 04, 2008 1:49 pm
Re: VERP support
Thanks for the info. What additional support for VERP are you planning to build into 4.x?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: VERP support
I haven't done it yet but it should just be a simple plugin. It's sitting on my TODO list along with other trivial things such as read-receipts.
-
gamegarage
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 04, 2008 8:52 am
Re: VERP support
Hi Chris,
Great work on the new version, it's excellent!
I have however been using a VERP plugin with v3 and am having trouble migrating it to v4. Is it still possible to use setReturnPath in beforeSendPerformed?
As a little test I tried using setSubject and it works.
Many thanks,
Nick
Great work on the new version, it's excellent!
I have however been using a VERP plugin with v3 and am having trouble migrating it to v4. Is it still possible to use setReturnPath in beforeSendPerformed?
Code: Select all
<?php
// Require Swift Mailer
require_once('./includes/lib/swift_required.php');
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
// Create the Mailer
$mailer = Swift_Mailer::newInstance($transport);
// Recipients
$rcpt_array = array('user@example.com');
$bounce_id_array = array('user@example.com' => 'verp-id');
// Create the message
$message = Swift_Message::newInstance()
->setSubject('Subject')
->setFrom(array('webmaster@example.com' => 'Example.com'))
->setTo($rcpt_array)
->setBody('Testing VERP plugin')
;
class Swift_Plugins_ReturnPathPlugin
implements Swift_Events_SendListener
{
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
{
// Reset return path for all users
$newReturnPath = '';
$message = $evt->getMessage();
$rcpt_array = $message->getTo();
if (count($rcpt_array) == 1)
{
$rcpt_email_keys = array_keys($rcpt_array);
$rcpt_email = array_pop($rcpt_email_keys);
if (array_key_exists($rcpt_email, $GLOBALS['bounce_id_array']))
$newReturnPath = 'b-' . $GLOBALS['bounce_id_array'][$rcpt_email] . '@example.com';
}
$message->setReturnPath($newReturnPath);
$message->setSubject('New subject');
}
public function sendPerformed(Swift_Events_SendEvent $evt)
{
}
}
$returnPath = new Swift_Plugins_ReturnPathPlugin();
$mailer->registerPlugin($returnPath);
$sent = $mailer->batchSend($message);
echo $sent;
Many thanks,
Nick
-
gamegarage
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 04, 2008 8:52 am
Re: VERP support
I think I've found the solution:
I moved the following code in Transport/AbstractSmtpTransport.php to after beforeSendPerformed:
I moved the following code in Transport/AbstractSmtpTransport.php to after beforeSendPerformed:
Code: Select all
if (!$reversePath = $this->_getReversePath($message))
{
throw new Swift_TransportException(
'Cannot send message without a sender address'
);
}