cividesk / com.cividesk.email.sparkpost

This extension allows CiviCRM to send emails and process bounces through the SparkPost service.
10 stars 30 forks source link

Cannot send test email #62

Open mattwire opened 6 years ago

mattwire commented 6 years ago

This commit https://github.com/cividesk/com.cividesk.email.sparkpost/commit/85a4a89162b2c5f273c95503da6902d7e49499ad breaks sending test emails for me. I didn't test whether it also breaks sending other email but I'm guessing it does.

When pressing "Save and Send Test Email" from: Administer->System Settings->Outbound Email (Sparkpost)

I get the following error:

Sending test email. FROM: XXX@XXX TO: YYY@YYY.
Oops. Your SparkPost settings are incorrect. No test mail has been sent.
An error occurred when CiviCRM attempted to send an email (via SMTP). If you received this error after submitting on online contribution or event registration - the transaction was completed, but we were unable to send the email receipt.

The mail library returned the following error message:
Sparkpost error: HTTP return code 405, Sparkpost error code 1102 (invalid http method: PUT is not supported on /api/v1/transmissions). Check https://support.sparkpost.com/customer/en/portal/articles/2140916-extended-error-codes for interpretation.

This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM » System Settings » Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:

Your Sendmail path is incorrect.
Your Sendmail argument is incorrect.
The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.
mattwire commented 6 years ago

Tagging @sunilpawar

sunilpawar commented 6 years ago

@mattwire can you confirm the sending domain (from email address)?

mattwire commented 6 years ago

@sunilpawar Sorry :-) FROM and TO are both valid email addresses - I replaced them with XXX and YYY for this ticket.

sunilpawar commented 6 years ago

@mattwire its working on our environment PHP : 5.6.35 cURL : 7.53.1 Can you confirm it by reverting these changes?

mattwire commented 6 years ago

@sunilpawar Sure, everything works perfectly with the previous commit: https://github.com/cividesk/com.cividesk.email.sparkpost/commit/b5b04fb02ef0e0b5f1959d8a379df272ce32ded7

I've tested on:

Both have the same issue.

sunilpawar commented 6 years ago

@nganivet look like curl re-use connection not working with php 7. lets discus this.

nganivet commented 6 years ago

@mattwire Thanks for reporting. Can you try adding curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); just before line 113 of CRM/Sparkpost.php and test to see if it fixes your issue?

nganivet commented 6 years ago

@mattwire Might need 'GET' instead of 'POST' in the above, not quite sure as the documentation is lacking. Can you try both and report back here? Thanks.

mattwire commented 6 years ago

@nganivet I replaced the existing line: curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); with curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

and that seems to fix the problem. Note that I tested with POST and that failed with a message 404 on creating webhook when trying to send a test email.

nganivet commented 6 years ago

@mattwire OK, we will fix the issue and release a new version. Thanks for your feedback.

nganivet commented 6 years ago

@mattwire Can you please test the latest commit and confirm it works on your side. Was a bit difficult to fix cleanly as documentation on CURLOPT_CUSTOMREQUEST is lacking and this is what caused the issue.

laryn commented 6 years ago

Using the latest dev it was not working and seemed to match what @mattwire describes here:

Note that I tested with POST and that failed with a message 404 on creating webhook when trying to send a test email.

I used the latest official release and patched the line suggested here and then the test email is reported as sending correctly (although I haven't received it yet).

mattwire commented 6 years ago

With this fix I get

SparkPost error
Could not install webhook (Sparkpost error: HTTP return code 404, Sparkpost error code (Resource could not be found: ). Check https://support.sparkpost.com/customer/en/portal/articles/2140916-extended-error-codes for interpretation.).

But changing line 44 to curl_setopt(self::$ch, CURLOPT_CUSTOMREQUEST, "GET"); per the original suggestion makes it work.

lsmithgo commented 6 years ago

why is this issue closed when it clearly is still an issue and the 1.2 version does not work?

mattwire commented 6 years ago

@lsmithgo github automatically closes them when you reference an issue in a commit message

mattwire commented 6 years ago

@nganivet @sunilpawar So the original one-liner suggestion curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); seems to work, but the actual changes and my subsequent PR #63 don't work - nothing actually gets received by Sparkpost.

sunilpawar commented 6 years ago

@mattwire @nganivet I have upgraded our development server to php 7.0.30 PHP 7.0.30 Curl : 7.40.0 Tested on Drupal (7.59), CiviCRM (4.7.31)

I changed CURLOPT_CUSTOMREQUEST value and sent test mail. Following are the result for different value. CURLOPT_CUSTOMREQUEST: NULL => Pass CURLOPT_CUSTOMREQUEST: 'GET' => Pass CURLOPT_CUSTOMREQUEST: 'POST' => Pass CURLOPT_CUSTOMREQUEST: 'PUT' => Fail

For Failed Result, following is the message. Sparkpost error: HTTP return code 405, Sparkpost error code 1102 (invalid http method: PUT is not supported on /api/v1/transmissions). Check https://support.sparkpost.com/customer/en/portal/articles/2140916-extended-error-codes for interpretation.

(branch: master with latest changes).

sunilpawar commented 6 years ago

@mattwire have you faced issue with web-hook ? its again related php 7.* with recent changes on CURLOPT_CUSTOMREQUEST

mattwire commented 6 years ago

@sunilpawar I didn't try the web-hook as I switched back to an older version on live sites until the issue with CUSTOMREQUEST is fully resolved.

andyburnsco commented 6 years ago

Same issue here, I tried the same fix that Matt tried but nothing happens. I revered back to ver 1.1.

robbrandt commented 6 years ago

I am getting the same error as @mattwire after I upgraded to CiviCRM 5.4.1 and v1.2 of this extension. I am using php 5.6.37 on Ubuntu 16.04.

robbrandt commented 6 years ago

Interestingly, just after I posted this comment I got a delayed receipt from our CiviCRM installation. I tried a test transaction first, didn't get a receipt immediately, then went to the sparkpost configuration to test it. I believe it is working OK on production tasks, but throwing this error only during the "test" function.

andyburnsco commented 6 years ago

capture

So I see that using ver 1.1 with Civi 5.4.0 prevents any jquery from working :(

rick02840 commented 5 years ago

Drupal 7.60, Civi 5.3.2, PHP 5.6.36, getting same error as others (below). Was there a recommended solution for this? Thanks.

The mail library returned the following error message:
Sparkpost error: HTTP return code 405, Sparkpost error code 1102 (invalid http method: PUT is not supported on /api/v1/transmissions). Check https://support.sparkpost.com/customer/en/portal/articles/2140916-extended-error-codes for interpretation.

This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM » System Settings » Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:

Your Sendmail path is incorrect.
Your Sendmail argument is incorrect.
The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.
Check this page for more information
mattwire commented 5 years ago

@rick02840 I use the extension based on this commit: https://github.com/cividesk/com.cividesk.email.sparkpost/commit/b5b04fb02ef0e0b5f1959d8a379df272ce32ded7 Just before all the CURL changes went in that broke things. That version works fine on all my sites.

rick02840 commented 5 years ago

Thanks I think that fixed it! The test email working now here: /civicrm/admin/setting/sparkpost?reset=1 ...will see if membership reminder emails start flowing again.
So I guess the update to 1.2 broke it. Thank you so much for responding!

rick02840 commented 5 years ago

Not sure if mail sending is working yet, but I am still seeing these errors below in Drupal logs (/admin/reports/dblog):

TYPE    civicrm
DATE    Tuesday, October 30, 2018 - 8:28pm
USER    civimail
LOCATION    https://myorganization.org/civicrm-cron/passthrough?key=302d240d8d732a72806a5e7da0f3b5da
REFERRER    
MESSAGE $backTrace = #0 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/CRM/Core/Error.php(339): CRM_Core_Error::backtrace("backTrace", TRUE) #1 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/CRM/Utils/Mail/EmailProcessor.php(175): CRM_Core_Error::fatal("Could not connect to MailStore for @smtp.sparkpostmail.com<p>Error message: <...") #2 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/CRM/Utils/Mail/EmailProcessor.php(59): CRM_Utils_Mail_EmailProcessor::_process(TRUE, Object(CRM_Core_DAO_MailSettings), 0) #3 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/api/v3/Job.php(368): CRM_Utils_Mail_EmailProcessor::processBounces(0) #4 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_job_fetch_bounces((Array:2)) #5 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9)) #6 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:7)) #7 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("Job", "fetch_bounces", (Array:1), NULL) #8 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/CRM/Core/JobManager.php(145): civicrm_api("Job", "fetch_bounces", (Array:1)) #9 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/civicrm/CRM/Core/JobManager.php(79): CRM_Core_JobManager->executeJob(Object(CRM_Core_ScheduledJob)) #10 /home/webserver/myorganization.org/profiles/cm_starterkit_moderate/modules/contrib/civicrm_cron/civicrm_cron.module(165): CRM_Core_JobManager->execute() #11 [internal function](): civicrm_cron_passthrough() #12 /home/webserver/myorganization.org/includes/menu.inc(527): call_user_func_array("civicrm_cron_passthrough", (Array:0)) #13 /home/webserver/myorganization.org/index.php(21): menu_execute_active_handler() #14 {main}
SEVERITY    debug
HOSTNAME    00.000.000.00
OPERATIONS  

TYPE    civicrm
DATE    Tuesday, October 30, 2018 - 8:28pm
USER    civimail
LOCATION    https://myorganization.org/civicrm-cron/passthrough?key=302d240d8d732a72806a5e7da0f3b5da
REFERRER    
MESSAGE $Fatal Error Details = Array ( [message] => Could not connect to MailStore for @smtp.sparkpostmail.com<p>Error message: <pre>An error occured while sending or receiving mail. Failed to connect to the server: smtp.sparkpostmail.com:993.</pre><p> [code] => )
SEVERITY    debug
HOSTNAME    00.000.000.00
OPERATIONS  

UPDATE: I may have settings wrong here: /civicrm/admin/mailSettings?reset=1 There was no username or pass. If I understand this correctly: https://app.sparkpost.com/account/smtp username should be: SMTP_Injection password should be: my sparkpost API key I put that in, will see what happens.

UPDATE: Nope, still seeing errors above, hourly on corn run.

sunilpawar commented 5 years ago

@mattwire @rick02840 Can you try these changes on top of v1.2

I have Tested this on our dev environment and its working for us. If this work for you, then i will push these changes to repository.

Additional Details: PHP 7.0.30 curl : 7.40.0 Drupa: 7.59, CiviCRM: 4.7.31

cdhassell commented 5 years ago

That patch still doesn't work for me. I can only make v1.2 work by backing out the curl optimizations commit as others have reported here.

php 7.0.32 wordpress 4.9.8 civicrm 5.5.3 curl 7.35.0