Comments (19)
I have the same problem... my site is hosted on GoDaddy. In the past I used the Mandrill and it worked fine using API method.
I think that the most compatible way is the API method... i'm waiting this change for use the SparkPost on all my sites. =)
from wordpress-sparkpost.
Same issue on BlueHost and Siteground. Both ports (and, possibly, the IP address of the SMTP server) are blocked, even on higher level plans.
from wordpress-sparkpost.
Same issue on BlueHost and Siteground. Both ports (and, possibly, the IP address of the SMTP server) are blocked, even on higher level plans.
@daigo75 Thanks for letting us know. Yes, we are aware and that's why we're actively working on a new version of this plugin that supports sending over HTTP. Stay with us :).
from wordpress-sparkpost.
@rajumsys Thanks for that. If I may, I would recommend not to use the approach, used by the wpMandrill plugin, of redeclaring the wp_mail()
function. That can cause conflicts quite often.
from wordpress-sparkpost.
I appreciate your input regarding that. Unfortunately, I found it similar that we can't achieve our goal without re-declaring wp_mail
. Seems it's not possible to patch wp_mail
dynamically (using hooks/filters). Probably, that's why they (WP/automattic) put it in pluggable.php
.
Let me know if you've other alternatives in mind. I'll be happy to look into that approach.
from wordpress-sparkpost.
@rajumsys If I were to do it, I would simply replace the PHPMailer instance and override the send()
method. It's not too complicated to do, I've adopted a similar solution in many cases, when there weren't filters that allowed to use a different approach.
from wordpress-sparkpost.
Example
Step 1 - Declare a custom mailer
/**
* Replaces the standard PHPMailer class, using SparkPost HTTP service to
* send emails.
* Since this class is derived from PHPMailer, consumers will be able to
* use it as they always did.
*/
class SparkPost_HTTP_Mailer extends PHPMailer {
/**
* Sends an email using SparkPost REST service.
*
* @return bool
*/
public function send() {
// Custom send logic here
return $this->send_mail_via_sparkpost();
}
}
Step 2 - Replace the mailer the first time an email is sent
The wp_mail
filter is invoked before any other mailing operation is performed, and can be used to override the PHPMailer instance.
add_filter('wp_mail', function($wp_mail_args) {
global $phpmailer;
if(!$phpmailer instanceof SparkPost_HTTP_Mailer) {
$phpmailer = new SparkPost_HTTP_Mailer();
}
return $wp_mail_args;
});
from wordpress-sparkpost.
That's super interesting. It's very smart how you're replacing the $phpmailer
. I'll give it a short. Much appreciated.
from wordpress-sparkpost.
I did that in the past with many other classes, working with WordPress and WooCommerce. Shipping methods, payment gateways, product classes, and none of the consumers ever noticed the difference. If you're careful, it just works. That's the beauty of OOP. 😄
If you have difficulties in making it work, I could patch your plugin myself. I just need to find some time for it. :)
Anecdote
In some cases, I replaced classes "before after I extended them". I needed to extend different classes, while still ensuring that all of them had common ancestor methods. Of course, you can't "tack" methods to an existing class, so I implemented a double inheritance logic.
- Class A (original)
- Class B (generated dynamically, with required methods) extends A.
- Class C extends B. Now C is an instance of A, with all the benefits of B.
100% backward compatible with A, and it works with any "A-type" class that may be added in the future. Et voilà.
from wordpress-sparkpost.
Following up, I came up with such a version (PoC) that works :). So, I'm heading to this direction now :).
from wordpress-sparkpost.
@rajumsys I knew it was easy. 😄 By the way, what does PoC mean?
from wordpress-sparkpost.
Proof of Concept :).
from wordpress-sparkpost.
Oh, I see. I didn't think about that. 😄
I thought it would be simple to do, as replacing the send()
method would simply mean calling your REST API, instead of sendmail
, and the parent PHPMailer
class already provides all the information you need (sender, recipients, body, etc).
from wordpress-sparkpost.
Yeah, I'm not exactly overriding send
directly. I'm implementing a new mailer. Looking into phpmailer source, I see it allows custom _mailer_
and calls _mailer_Send
like spMailer
if name of our mailer is sp
. But there are lot of other things to take care of :).
from wordpress-sparkpost.
@daigo75 A PR is submitted. Your input is appreciated :).
from wordpress-sparkpost.
I'm not sure how the new class overrides the sending, since it doesn't replace the send()
method, but the rest seems ok to me (I didn't have much time to test it, yet).
from wordpress-sparkpost.
@daigo75
#4 (comment). Check isMail
method. Bcoz we declared a new mailer, it calls sparkpostSend
.
from wordpress-sparkpost.
I see now. I would probably just have replaced the send()
method, to keep things linear (no need to keep the old method, since it's never going to be used).
from wordpress-sparkpost.
Can we close this now?
from wordpress-sparkpost.
Related Issues (20)
- Allow option to raise email exceptions HOT 1
- Support adding Campaign tag HOT 1
- Newly installed sparkpost plugin, getting SSL error: Failed to enable crypto HOT 3
- Show admin-wide alert if plugin is not ready to send!
- BuddyPress not sent with SparkPost HOT 3
- Why is Content-Type unsupported? HOT 9
- API Transmission Endpoint Changes HOT 2
- Retry transmissions after 5xx Error HOT 1
- Sparkpost replaces the url with a custom url HOT 3
- Emails could not be sent. htmlentities() expects parameter 1 to be string, array given in xxx HOT 8
- Missing assets folder in plugin installation HOT 6
- Retry transmissions after cURL error
- QUIT
- Sparkpost for only one contact form?
- reply-to not working
- Disable SparkPost mailer using a PHP constant
- Plugin uses incorrect bounce domain HOT 1
- Wondering if this plugin is still being maintained? HOT 1
- Deprecated notice on WP 5.5 HOT 2
- Fatal error: Uncaught Error in PHPMailer HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wordpress-sparkpost.