Comments (2)
Different SMTP plugins handle email sending differently. Even if it returns as true then it does not mean the email was sent.
Some plugins actually queue the mails first and send them later.
So in the WP environment, it's quite impossible to know if the email actually sent or not. If you use FluentSMTP or Amazon SES and set up SNS then it sent a notification if an email failed to send.
Mailer::send()
's job is to deliver the emails to wp_mail() and nothing else. Then we listen for SNS or webhook for other SMTP services to mark as bounced.
from fluent-crm.
@techjewel yes it doesnt reflect mail sucess per se but that wp_mail worked as intended. In fact if a SMTP plugin does not return either bool(true) or bool(false) for wp_mail it should be uninstalled immediately as it violates the contract provided by WordPress core.
FluentSMTP returns only boolean true/false so whats the point of checking for WP_Error.
Be so kind and make the following test. Install the lastet version of FluentCRM, and create a contact. Now before you send him an email go into wp_mail and just add this
/**
* Sends an email, similar to PHP's mail function.
*
* A true return value does not automatically mean that the user received the
* email successfully. It just only means that the method used was able to
* process the request without any errors.
*
* The default content type is `text/plain` which does not allow using HTML.
* However, you can set the content type of the email by using the
* {@see 'wp_mail_content_type'} filter.
*
* The default charset is based on the charset used on the blog. The charset can
* be set using the {@see 'wp_mail_charset'} filter.
*
* @since 1.2.1
* @since 5.5.0 is_email() is used for email validation,
* instead of PHPMailer's default validator.
*
* @global PHPMailer\PHPMailer\PHPMailer $phpmailer
*
* @param string|string[] $to Array or comma-separated list of email addresses to send message.
* @param string $subject Email subject.
* @param string $message Message contents.
* @param string|string[] $headers Optional. Additional headers.
* @param string|string[] $attachments Optional. Paths to files to attach.
* @return bool Whether the email was sent successfully.
*/
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
return false;
// code
}
That email will never ever get send but is marked as successful in the UI including a flash massage. This is super misleading for users that don't know whats going on.
While bool(true)
cant guarantee that the email was sent successfully bool(false)
almost 100% percent guarantees that it did not work.
Relying on the handleFailedLog
function is a bad solution. What happens if an uncaught exception gets thrown? That hook will never fire.
A more reasonable approach would be the following.
foreach ($campaignEmails as $email) {
if ($this->reachedEmailLimitPerSecond()) {
$this->restartWhenOneSecondExceeds();
} else {
try {
$mail_sent_successfully = Mailer::send($email->data());
$this->dispatchedWithinOneSecond++;
}catch (\Throwable $e ) {
error_log($e->getMessage() . 'TRACE:' . $e->getTraceAsString());
$mail_sent_successfully = false;
}
if ( ! $mail_sent_successfully) {
$failedIds[] = $email->id;
} else {
CampaignEmail::where('id', $email->id)->whereNot('status', 'failed')->update([
'status' => 'sent',
'updated_at' => current_time('mysql')
]);
$sentIds[] = $email->id;
}
}
}
from fluent-crm.
Related Issues (20)
- [BUG] A trigger has to have at least one default value for conditions or no conditions will show in the UI. HOT 1
- [BUG] missing 'created_by' column in fluentcrm_update_subscriber_meta HOT 1
- [BUG] When using wp user account sync and updating the email adress in FluentCRM the user_id column will be lost. HOT 2
- [BUG] Clicking "tags" in the dashboard view does not redirect the user to the tags page. HOT 1
- [BUG] Bug in WPOrm causes overwritting of model events. HOT 1
- [BUG] Sending custom emails via the dashboard totally disregards subscriber status and gives false positive success message. HOT 1
- Problem with downloading localization files
- [BUG] changing a contacts email address will not update scheduled campaign emails. HOT 3
- [Enhancement] Extract function that retrieves all public list Ids out of ExternalPages.php HOT 1
- Grammer and spelling
- "+ Add Contact" Status is "Subscribed"
- Some missing countries
- Stop using the development autoloader. HOT 1
- Fetch a new WordPress Nonce if the current one is expired. HOT 1
- Open Rates (I know they're always flawed but this is different) HOT 1
- Error in API documentation: Get contact by user_id HOT 1
- [Enhancment] Add filter to allow adding of custom icons for funnel categories HOT 1
- [BUG] Unable to create new lists while creating a funnel trigger. HOT 1
- [BUG] User Login trigger will run an indefinate amount of times for the same user regardless of settings HOT 1
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 fluent-crm.