Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invitation email not being sent #171

Open
pgrafix opened this issue Nov 3, 2022 · 5 comments
Open

Invitation email not being sent #171

pgrafix opened this issue Nov 3, 2022 · 5 comments

Comments

@pgrafix
Copy link

pgrafix commented Nov 3, 2022

We are trying to integrate IA into our BP setup. In testing, we have found that although a success message is displayed after sending an email invite that the email itself is not being sent. We are using the WP SMTP plugin to send transactional emails via Mailgun. I can confirm that:

  1. The email never gets logged on the Mailgun side. Thus, it never left WP.
  2. There are no errors pertaining to a failure in the serve logs.

We have run the fix for missing IA templates from https://gist.github.com/boonebgorges/03945bad2fd6870f608eb5affd853f83 as stated by you in https://wordpress.org/support/topic/invitation-emails-not-sent/. While the missing email templates were created, it did not restore the sending of the invitation.

As also outlined in https://wordpress.org/support/topic/invitation-emails-not-sent/, If line 1358 of the by-email.php is commented out then the emails finally get sent. However, this is just a band aid since the change would be overwritten on every IA update.

Please advise.

And thank you for your work!

@boonebgorges
Copy link
Owner

Hello and thanks for the ticket.

Can you confirm that this is the plugin that you use for email sending? https://wordpress.org/plugins/wp-smtp/

Perhaps the best recommendation I can make for further debugging is to collect the return value of bp_send_email() on this line https://github.com/boonebgorges/invite-anyone/blob/1.4.x/by-email/by-email.php#L1378 and log it somehow. For example:

$email_results = bp_send_email( 'invite-anyone-invitation', $to, $bp_email_args );
error_log( print_r( $email_results, true ) );

Instead of error_log() you can use whatever other logging tools you have at your disposal.

@pgrafix
Copy link
Author

pgrafix commented Nov 4, 2022

Thank you for the response.

Yes, that is indeed the plugin.

I instituted your logging code beginning on line 1379 but nothing is getting logged. I attempted to run the second line as error_log( $email_results, 0 ); as well, but still nothing gets logged. According to Cloudways documentation, error_log is being implemented as they instruct to, so not sure where the logging process is breaking. I even went as far as to using json_encode to echo the value of $email_results to the console but it is returning nothing as well.

@boonebgorges
Copy link
Owner

I can't give in-depth advice on how best to run error reporting across platforms and configurations. For instance, it could be that logging is being blocked at the WP level (WP_DEBUG is false) or at the PHP level (error_reporting(0) or the like).

The following should be config-independent:

$file = 'some/writeable/log/path/on/your/server.log';
$log_entry = print_r( $email_results, true ); // You must do this in order to create a string out of the WP_Error object
error_log( date( '[Y-m-d H:i:s]' ) . ' ' . $content . "\n", 3, $file );

Hopefully that helps, or perhaps you can rig up some other way of logging (even a var_dump() or something).

@pgrafix
Copy link
Author

pgrafix commented Nov 17, 2022

I have the logging code using this:

$email_results = bp_send_email( 'invite-anyone-invitation', $to, $bp_email_args );
$file = (WP_CONTENT_DIR . "/" . 'invite_anyone.log');
$log_entry = print_r( $email_results, true ); // You must do this in order to create a string out of the WP_Error object
error_log( date( '[Y-m-d H:i:s]' ) . ' ' . $log_entry . "\n", 3, $file );

If I use $content as indicated in your code the log is blank. Using $log_entry seems to return as simple binary of 1. Here are the logs:

[2022-11-17 17:52:01]
[2022-11-17 17:53:01] 1

Line 1 is using $content. Line 2 is using $log_entry

@boonebgorges
Copy link
Owner

Sorry, yes, $content was obviously an error. $log_entry is the proper variable.

The fact that you're getting a 1 means that bp_send_email() is returning true. This is unexpected, and I'm not sure how to interpret it.

You say that Mailgun is not showing anything; do the wp-smtp logs show any outgoing mail?

I guess you could try digging deeper into the BP_PHPMailer class and then into WP's PHPMailer to see if you can identify where the process is getting hung up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants