FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Swiftmailer mod for 'return-path'
#1
I left a post in the Form Tools / Modules / Other / Swiftmailer / Feature Requests thread asking for access to the header 'return-path' value for email. In the meantime I have a mod in place that puts a single email address into all Swiftmailer generated email for both text and html formats. The script I altered was:

formtools/modules/swift_mailer/library.php

Code:
// now send the appropriate email
  if (!empty($email_components["text_content"]) && !empty($email_components["html_content"]))
  {
    $email =& new Swift_Message($email_components["subject"]);
    $email->attach(new Swift_Message_Part($email_components["text_content"]));
    $email->attach(new Swift_Message_Part($email_components["html_content"], "text/html"));
  }
  else if (!empty($email_components["text_content"]))
    {
    $email =& new Swift_Message($email_components["subject"]);

$email->setReturnPath('webmaster@example.com'); // THIS IS 1 of 2 NEW LINES

        $email->attach(new Swift_Message_Part($email_components["text_content"]));
    }
  else if (!empty($email_components["html_content"]))
    {
    $email =& new Swift_Message($email_components["subject"]);

$email->setReturnPath('webmaster@example.com'); // THIS IS 2 of 2 NEW LINES

        $email->attach(new Swift_Message_Part($email_components["html_content"], "text/html"));
    }

This places the same return-path email on top of all email generated by Swiftmailer. I hope this helps others looking for a similar solution. Maybe this can make the official list as a feature request.

Enjoy!
Chuck
Reply
#2
This is terrific! Thanks for posting your solution, Chuck.

I'll definitely keep this in mind for future versions of the Swift Mailer module. What I'll probably do is make this a configurable option on the Edit Template page so users can enter it there.

- Ben
Reply
#3
(Apr 5th, 2009, 9:02 PM)Ben Wrote: This is terrific! Thanks for posting your solution, Chuck.

I'll definitely keep this in mind for future versions of the Swift Mailer module. What I'll probably do is make this a configurable option on the Edit Template page so users can enter it there.

- Ben

I'm not completly sure but you might want to consider adding a third line for the emails that have attachments:

Code:
// now send the appropriate email
  if (!empty($email_components["text_content"]) && !empty($email_components["html_content"]))
  {
    $email =& new Swift_Message($email_components["subject"]);

$email->setReturnPath('webmaster@example.com'); // ADDITIONAL THIRD NEW LINE

    $email->attach(new Swift_Message_Part($email_components["text_content"]));
    $email->attach(new Swift_Message_Part($email_components["html_content"], "text/html"));
  }
  else if (!empty($email_components["text_content"]))
    {
    $email =& new Swift_Message($email_components["subject"]);

$email->setReturnPath('webmaster@example.com'); // THIS IS 1 of 2 NEW LINES

        $email->attach(new Swift_Message_Part($email_components["text_content"]));
    }
  else if (!empty($email_components["html_content"]))
    {
    $email =& new Swift_Message($email_components["subject"]);

$email->setReturnPath('webmaster@example.com'); // THIS IS 2 of 2 NEW LINES

        $email->attach(new Swift_Message_Part($email_components["html_content"], "text/html"));
    }

I haven't tested the third line but it looks like it should work.

Thank you Ben!
Reply
#4
Hey Chuck,

I really liked your idea for this, so I've added it to the main core script.

See the documentation here:
http://modules.formtools.org/swift_maile...ble_emails

Basically, a new field shows up on your Edit Email Template » Recipient tab, labeled "Undeliverable Email Recipient", where you can enter a custom email recipient for each email template.

Note: it WILL require you to be running the latest version of the Form Tools Core, too. So when upgrading, just select both the Core + the Swift Mailer module.

Enjoy!

- Ben
Reply
#5
(Apr 9th, 2009, 5:11 PM)Ben Wrote: See the documentation here:
http://modules.formtools.org/swift_maile...ble_emails

Sweet! Thanks Ben!

Just a note to others on the upgrade. After downloading the upgrade code and installing it onto my site I had to visit the Modules section and click on the Upgrade link for Swiftmailer. No big deal but if you don't take this step the new functionality won't be active.
Reply
#6
Good point - thanks for mentioning that.
Reply
#7
Thanks for posting your solution
electronic cigarette manufacturer provide health electronic cigarettes,E-liquid,e-solid,EGO-T, joye510 etc
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)