SparkPost Mail Transport

SparkPost Mail Transport 1.1.0

No permission to download

Sim

Well-known member
Sim submitted a new resource:

SparkPost Mail Transport - Swiftmailer Transport implementation for SparkPost

Adds a SparkPost mail transport option to have all mails sent via your SparkPost account.

This addon has full bounced email and unsubscribed email handling support using the SparkPost Events API - no mailbox required.

View attachment 215391

Setup

If you haven't already done so, you will need to configure a sending domain for your forum in your SparkPost account. It is highly recommended that you also set up a...

Read more about this resource...
 

Sim

Well-known member
@Sim Please can you make addon for postmarkapp.com? So we can use postmarkapp API Tokens key with Xenforo with Bounce and Unsubscribe Handling support.

I use SparkPost, which is why I wrote this addon. I don't have time to write or support addons for other email providers - sorry.
 

Sim

Well-known member
@Sim How to create Webhook in SparkPost? I am getting error with Webhook URL https://mysite.com

View attachment 220470

Your webhook must return a HTTP 200 response.

  • Any webhook batch that does not receive an HTTP 200 response will be retried for a total of 8 hours before the data is discarded.
  • Webhooks posting to your endpoint will timeout after 10 seconds. For best results, write webhook batches to disk and then process asynchronously to minimize data loss if you have a problem with your database.
I'm curious about why you are creating a webhook?
 

Ablac

Active member
Im getting a failed to send error?

Expand log details
!! Failed to send transmission to SparkPost (code: 0)

EDIT: Sorted it out, realized I didnt put the Sending Email address in haha DER...
 

ekempter

Active member
Enhancement request. The ability to include a campaign name for each email. This would help to identify individual advertiser statistics within Sparkpost. Perhaps a user designated string(s) (advertiser banner URL) associated with a campaign?
 

Foynat

Member
@Sim, I'm very interested in this as it does a lot of what a custom add-on I had written for my old VBulletin with Sendgrid setup did. I would consider moving from Sendgrid to Sparkpost for this.

You wrote " Note that if we receive a hard bounce for transactional emails - the users account will be disabled to prevent further emails being sent. "

Forgive my ignorance of how XenForo works, but would the user then be prompted to change their email and reactivate their account, (ideally after clicking a link in an email sent by Xenforo to validate their new email address)? Or would that user just be written off? Thanks for any insight you can give.
 

Foynat

Member
Oops sorry I thought this was a commercial add-on. Very generous of you to release it @Sim and I will do some testing to find out the answer to my previous question.
 

Sim

Well-known member
@Sim, I'm very interested in this as it does a lot of what a custom add-on I had written for my old VBulletin with Sendgrid setup did. I would consider moving from Sendgrid to Sparkpost for this.

You wrote " Note that if we receive a hard bounce for transactional emails - the users account will be disabled to prevent further emails being sent. "

Forgive my ignorance of how XenForo works, but would the user then be prompted to change their email and reactivate their account, (ideally after clicking a link in an email sent by Xenforo to validate their new email address)? Or would that user just be written off? Thanks for any insight you can give.

This addon simply uses the built-in bounced email processing which puts the user into the "Email invalid (bounced)" state.

This will then cause the following message to display to a user when they log in:

1593637140102.png

So yes, they will be prompted to change their email and reactivate their account.
 

Sim

Well-known member
Hey there,

So I'm getting these errors:


Any idea on how to fix it?

Were there any server errors logged?

Have you configured your Default email address in XenForo?

Does the domain of that email address match a sending domain you've configured in SparkPost?

Note: you cannot have your sending email address as Outlook or Gmail etc - must be a domain you own.
 

Unique Username

Well-known member
Have you configured your Default email address in XenForo?
I had hit set to mail@mydomain.com

Were there any server errors logged?
Code:
    Swift_TransportException: Email to milkman96@outlook.com failed: Failed to send transmission to SparkPost src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php:212

    Generated by: Unknown account Jul 4, 2020 at 9:10 PM

Stack trace

#0 src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php(190): SwiftSparkPost\Transport->createAndDispatchTransportException('Failed to send ...', Object(SparkPost\SparkPostException))
#1 src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php(117): SwiftSparkPost\Transport->sendTransmission(Array)
#2 src/XF/Mail/Mailer.php(292): SwiftSparkPost\Transport->send(Object(SwiftSparkPost\Message), Array)
#3 src/XF/Mail/Queue.php(138): XF\Mail\Mailer->send(Object(SwiftSparkPost\Message), Object(SwiftSparkPost\Transport), Array)
#4 src/XF/Job/MailQueue.php(12): XF\Mail\Queue->run(G)
#5 src/XF/Job/Manager.php(253): XF\Job\MailQueue->run(G)
#6 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#7 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#8 job.php(42): XF\Job\Manager->runQueue(false, 8)
#9 {main}

-------------

Previous SparkPost\SparkPostException: { "errors": [ { "message": "Invalid domain", "description": "Unconfigured Sending Domain <mydomaing.com> ", "code": "7001" } ] } - src/addons/Hampel/SparkPostMail/vendor/sparkpost/sparkpost/lib/SparkPost/SparkPostPromise.php:77
#0 src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php(185): SparkPost\SparkPostPromise->wait()
#1 src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php(117): SwiftSparkPost\Transport->sendTransmission(Array)
#2 src/XF/Mail/Mailer.php(292): SwiftSparkPost\Transport->send(Object(SwiftSparkPost\Message), Array)
#3 src/XF/Mail/Queue.php(138): XF\Mail\Mailer->send(Object(SwiftSparkPost\Message), Object(SwiftSparkPost\Transport), Array)
#4 src/XF/Job/MailQueue.php(12): XF\Mail\Queue->run(G)
#5 src/XF/Job/Manager.php(253): XF\Job\MailQueue->run(G)
#6 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#7 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#8 job.php(42): XF\Job\Manager->runQueue(false, 8)
#9 {main}

-------------

Previous GuzzleHttp\Exception\ClientException: Client error: `POST https://api.sparkpost.com/api/v1/transmissions/` resulted in a `400 Bad Request` response:
{ "errors": [ { "message": "Invalid domain", "description": "Unconfigured Sending Domain <mydomain.com> ", "code": "700 (truncated...)
 - src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
#0 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(119): GuzzleHttp\Promise\TaskQueue->run()
#5 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(146): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#7 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#9 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 src/addons/Hampel/SparkPostMail/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#11 src/addons/Hampel/SparkPostMail/vendor/php-http/guzzle6-adapter/src/Promise.php(95): GuzzleHttp\Promise\Promise->wait(false)
#12 src/addons/Hampel/SparkPostMail/vendor/sparkpost/sparkpost/lib/SparkPost/SparkPostPromise.php(73): Http\Adapter\Guzzle6\Promise->wait(true)
#13 src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php(185): SparkPost\SparkPostPromise->wait()
#14 src/addons/Hampel/SparkPostMail/vendor/f500/swiftmailer-sparkpost/src/Transport.php(117): SwiftSparkPost\Transport->sendTransmission(Array)
#15 src/XF/Mail/Mailer.php(292): SwiftSparkPost\Transport->send(Object(SwiftSparkPost\Message), Array)
#16 src/XF/Mail/Queue.php(138): XF\Mail\Mailer->send(Object(SwiftSparkPost\Message), Object(SwiftSparkPost\Transport), Array)
#17 src/XF/Job/MailQueue.php(12): XF\Mail\Queue->run(G)
#18 src/XF/Job/Manager.php(253): XF\Job\MailQueue->run(G)
#19 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#20 src/XF/Job/Manager.php(79): XF\Job\Manager->runJobEntry(Array, G)
#21 job.php(42): XF\Job\Manager->runQueue(false, 8)
#22 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(31) "https://mydomain.com/index.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Does the domain of that email address match a sending domain you've configured in SparkPost?
Yeah, I set it as mail.mydomain.com.
 

Sim

Well-known member
{ "message": "Invalid domain", "description": "Unconfigured Sending Domain <mydomaing.com> ", "code": "7001" }

You haven't configured a sending domain in SparkPost yet.
 
Top