Page 1 of 1

VERP support

Posted: Tue Mar 04, 2008 1:51 pm
by gmorehoudh
What is the status of VERP support in Swift Mailer?

Re: VERP support

Posted: Tue Mar 04, 2008 4:52 pm
by Chris Corbyn
Coming in v4.

Re: VERP support

Posted: Tue Mar 04, 2008 5:52 pm
by gmorehoudh
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.

Re: VERP support

Posted: Tue Mar 04, 2008 6:34 pm
by Chris Corbyn
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.

Re: VERP support

Posted: Tue Mar 04, 2008 6:38 pm
by gmorehoudh
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.

Re: VERP support

Posted: Tue Mar 04, 2008 6:39 pm
by Chris Corbyn

Code: Select all

$message->headers->set('Sender', $something);

Re: VERP support

Posted: Tue Mar 04, 2008 7:13 pm
by gmorehoudh
Thanks for the info. What additional support for VERP are you planning to build into 4.x?

Re: VERP support

Posted: Tue Mar 04, 2008 7:38 pm
by Chris Corbyn
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.

Re: VERP support

Posted: Wed May 06, 2009 6:40 am
by gamegarage
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?

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;
 
As a little test I tried using setSubject and it works.

Many thanks,

Nick

Re: VERP support

Posted: Wed May 06, 2009 10:47 am
by gamegarage
I think I've found the solution:

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'
  );
}