Drupal 7 site emails not working - notifications disabled - drupal

I'm working on migrating a Drupal 7.1 site. After migrating the site to the new server, email notifications don't seem to be working (even though I'm using the same SMTP config as in the old server).
When going to the SMTP Authentication Support module settings and trying to send a test email, I get the following error message in the logs:
notifications disabled - discarding email to address:XXX, message: Array ( [id] => smtp_smtp-test [module] => smtp [key] => smtp-test [to] => XXX [from] => XXX [language] => stdClass Object ( [language] => en [name] => English [native] => English [direction] => 0 [enabled] => 1 [plurals] => 0 [formula] => [domain] => [prefix] => [weight] => 0 [javascript] => ) [params] => Array ( [subject] => Drupal SMTP test e-mail [body] => Array ( [0] => If you receive this message it means your site is capable of using SMTP to send e-mail. ) ) [send] => [subject] => Drupal SMTP test e-mail [body] => Array ( [0] => If you receive this message it means your site is capable of using SMTP to send e-mail. ) [headers] => Array ( [MIME-Version] => 1.0 [Content-Type] => text/plain; charset=UTF-8; format=flowed; delsp=yes [Content-Transfer-Encoding] => 8Bit [X-Mailer] => Drupal [Return-Path] => XXX [Sender] => XXX [From] => XXX ) )
The module itself indicates that the SMTP module is active, and the SMTP credentials are correct. I've tried looking into this "notifications disabled" but I don't see any setting that could be preventing notifications from being enabled.
Any idea of what could be going on here or where to start looking?

Related

Wordpress Paypal Error after Paypal express checkout button is pressed

I'm getting an error such as this after updating Woocommerce to its latest version.
PayPal error (10002): An error (10002) occurred while processing your PayPal payment. Please contact the store owner for assistance.
This is my error log:
06-05-2020 # 15:33:45 - WC_Gateway_PPEC_Client::_request: remote request to https://api-3t.paypal.com/nvp with params: Array
(
[LOGOIMG] => https://public-health-safety.com/wp-content/uploads/2019/06/PHS-Logo-150x72.jpg
[HDRIMG] =>
[PAGESTYLE] =>
[BRANDNAME] => PHS
[RETURNURL] => https://public-health-safety.com/checkout/?woo-paypal-return=true
[CANCELURL] => https://public-health-safety.com/cart/?woo-paypal-cancel=true
[LANDINGPAGE] => Login
[SOLUTIONTYPE] => Sole
[PAYMENTREQUEST_0_PAYMENTACTION] => sale
[PAYMENTREQUEST_0_INSURANCEAMT] => 0
[PAYMENTREQUEST_0_HANDLINGAMT] => 0
[PAYMENTREQUEST_0_CUSTOM] =>
[PAYMENTREQUEST_0_INVNUM] =>
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_AMT] => 190
[PAYMENTREQUEST_0_ITEMAMT] => 190
[PAYMENTREQUEST_0_SHIPPINGAMT] => 0
[PAYMENTREQUEST_0_TAXAMT] => 0
[PAYMENTREQUEST_0_SHIPDISCAMT] => 0
[NOSHIPPING] => 0
[EMAIL] => phsinc33#yahoo.com
[PAYMENTREQUEST_0_SHIPTONAME] =>
[PAYMENTREQUEST_0_SHIPTOSTREET] => 1528 W Adams
[PAYMENTREQUEST_0_SHIPTOSTREET2] =>
[PAYMENTREQUEST_0_SHIPTOCITY] => Chicago
[PAYMENTREQUEST_0_SHIPTOSTATE] => IL
[PAYMENTREQUEST_0_SHIPTOZIP] => 60607
[PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE] => US
[PAYMENTREQUEST_0_SHIPTOPHONENUM] => 3124910081
[L_PAYMENTREQUEST_0_NAME0] => AA 20-0608 - Asbestos Awareness 4-hour Training CAMICB
[L_PAYMENTREQUEST_0_DESC0] => ASBESTOS AWARENESS 4-HR TRAINING
Qualifies:
Per requirement of Community Association Managers International Certification
[L_PAYMENTREQUEST_0_QTY0] => 2
[L_PAYMENTREQUEST_0_AMT0] => 95
[L_PAYMENTREQUEST_0_NUMBER0] =>
[METHOD] => SetExpressCheckout
[VERSION] => 120.0
[USER] =>
[PWD] =>
[SIGNATURE] =>
)
06-05-2020 # 15:33:45 - WC_Gateway_PPEC_Client::_process_response: acknowleged response body: Array
(
[TIMESTAMP] => 2020-06-05T20:33:45Z
[CORRELATIONID] => ca25e49242d8a
[ACK] => Failure
[VERSION] => 120.0
[BUILD] => 54596016
[L_ERRORCODE0] => 10002
[L_SHORTMESSAGE0] => Authentication/Authorization Failed
[L_LONGMESSAGE0] => You do not have permissions to make this API call
[L_SEVERITYCODE0] => Error
)
Please help!
It appears as though you need to set your API credentials (User/Password/Signature).
They can be obtained via https://www.paypal.com/api

How to get raw values in latest Wordpress Rest API v2?

When requesting posts/pages/media with Wordpress Rest API v2 I used to receive a 'raw' and a 'rendered' value for fields like title, guid and content. With the latest Wordpress version the 'raw' fields seems to have vanished. I need the raw data as this is stable over time. Plugins can add (changing) data to the rendered data.
Is there a (header) parameter I need to provide in the API call to get raw data?
Original data returned (fragment):
Array
(
[id] => 1016
[date] => 2017-11-08T16:18:29
[date_gmt] => 2017-11-08T15:18:29
[guid] => Array
(
[rendered] => https://example.com/wp-content/uploads/2017/03/image.jpg
[raw] => https://example.com/wp-content/uploads/2017/03/image.jpg
)
[modified] => 2017-11-08T16:18:39
[modified_gmt] => 2017-11-08T15:18:39
[slug] => 888
[status] => inherit
[type] => attachment
[link] => https://example.com/review/shopper/attachment/test/
[title] => Array
(
[raw] => shopper image
[rendered] => shopper image
)
Latest WP API data:
Array
(
[id] => 1016
[date] => 2017-11-08T16:18:29
[date_gmt] => 2017-11-08T15:18:29
[guid] => Array
(
[rendered] => https://example.com/wp-content/uploads/2017/03/image.jpg
)
[modified] => 2017-11-08T16:18:39
[modified_gmt] => 2017-11-08T15:18:39
[slug] => 888
[status] => inherit
[type] => attachment
[link] => https://example.com/review/shopper/attachment/test/
[title] => Array
(
[rendered] => shopper image
)
The API URL:
https://example.com/wp-json/wp/v2/media/32
Edit:
I'm using oAuth1 for authentication (https://wordpress.org/plugins/rest-api-oauth1/). Given that raw values are not returned unauthenticated, I'm starting to suspect that this plugin has issues sending the authentication during the information gathering.
You have to pass 'context' = 'edit' to get the raw content.
Or you can use this plugin: https://github.com/w1z2g3/wordpress-plugins/blob/master/post-raw-content.php

Wordpress4.9.1 SMTP not working

I am using the WP mail SMTP (0.11.2) plugin.
usingWordpress4.9.1
When I sent my email it gives me this error SMTP -> ERROR: Failed to connect to server or Could not authenticate.
How can I fix it?
C:\wamp64\www\wordpress\wp-content\plugins\wp-mail-smtp\wp_mail_smtp.php:258:boolean false
Here is my testmail debuging info:
PHPMailer Object
(
[Version] => 5.2.22
[Priority] =>
[CharSet] => UTF-8
[ContentType] => text/plain
[Encoding] => 8bit
[ErrorInfo] => SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
[From] => xxxxxxxxxx#gmail.com
[FromName] => 搖滾俱樂部
[Sender] =>
[ReturnPath] =>
[Subject] => WP Mail SMTP: Test mail to bb5566123com#yahoo.com.tw
[Body] => 這封測試郵件由 WordPress 外掛 WP Mail SMTP 自動產生。
[AltBody] =>
[Ical] =>
[MIMEBody:protected] => 這封測試郵件由 WordPress 外掛 WP Mail SMTP 自動產生。
[MIMEHeader:protected] => Date: Fri, 8 Dec 2017 14:51:09 +0000
To: xxxxxxxxx#yahoo.com.tw
From: =?UTF-8?B?5pCW5ru+5L+x5qiC6YOo?=
Subject: WP Mail SMTP: Test mail to bb5566123com#yahoo.com.tw
Message-ID: <1d6e4a91953547c850de852e798ccbba#club3.idv.tw>
X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[mailHeader:protected] =>
[WordWrap] => 0
[Mailer] => smtp
[Sendmail] => /usr/sbin/sendmail
[UseSendmailOptions] => 1
[PluginDir] =>
[ConfirmReadingTo] =>
[Hostname] =>
[MessageID] =>
[MessageDate] => Fri, 8 Dec 2017 14:51:09 +0000
[Host] => smtp.gmail.com
[Port] => 465
[Helo] =>
[SMTPSecure] => ssl
[SMTPAutoTLS] => 1
[SMTPAuth] => 1
[SMTPOptions] => Array
(
)
[Username] => xxxxxxxxxxx#gmail.com
[Password] => xxxxxxxxxxxx
[AuthType] =>
[Realm] =>
[Workstation] =>
[Timeout] => 300
[SMTPDebug] => 0
[Debugoutput] => echo
[SMTPKeepAlive] =>
[SingleTo] =>
[SingleToArray] => Array
(
)
[do_verp] =>
[AllowEmpty] =>
[LE] =>
[DKIM_selector] =>
[DKIM_identity] =>
[DKIM_passphrase] =>
[DKIM_domain] =>
[DKIM_private] =>
[DKIM_private_string] =>
[action_function] =>
[XMailer] =>
[smtp:protected] => SMTP Object
(
[Version] => 5.2.22
[SMTP_PORT] => 25
[CRLF] =>
[do_debug] => 0
[Debugoutput] => echo
[do_verp] =>
[Timeout] => 300
[Timelimit] => 300
[smtp_transaction_id_patterns:protected] => Array
(
[exim] => /[0-9]{3} OK id=(.*)/
[sendmail] => /[0-9]{3} 2.0.0 (.*) Message/
[postfix] => /[0-9]{3} 2.0.0 Ok: queued as (.*)/
)
[smtp_conn:protected] =>
[error:protected] => Array
(
[error] =>
[detail] =>
[smtp_code] =>
[smtp_code_ex] =>
)
[helo_rply:protected] =>
[server_caps:protected] =>
[last_reply:protected] =>
)
[to:protected] => Array
(
[0] => Array
(
[0] => xxxxxxxxxx#yahoo.com.tw
[1] =>
)
)
[cc:protected] => Array
(
)
[bcc:protected] => Array
(
)
[ReplyTo:protected] => Array
(
)
[all_recipients:protected] => Array
(
[xxxxxxxxxxx#yahoo.com.tw] => 1
)
[RecipientsQueue:protected] => Array
(
)
[ReplyToQueue:protected] => Array
(
)
[attachment:protected] => Array
(
)
[CustomHeader:protected] => Array
(
)
[lastMessageID:protected] => <1d6e4a91953547c850de852e798ccbba#club3.idv.tw>
[message_type:protected] => plain
[boundary:protected] => Array
(
[1] => b1_1d6e4a91953547c850de852e798ccbba
[2] => b2_1d6e4a91953547c850de852e798ccbba
[3] => b3_1d6e4a91953547c850de852e798ccbba
)
[language:protected] => Array
(
[authenticate] => SMTP Error: Could not authenticate.
[connect_host] => SMTP Error: Could not connect to SMTP host.
[data_not_accepted] => SMTP Error: data not accepted.
[empty_message] => Message body empty
[encoding] => Unknown encoding:
[execute] => Could not execute:
[file_access] => Could not access file:
[file_open] => File Error: Could not open file:
[from_failed] => The following From address failed:
[instantiate] => Could not instantiate mail function.
[invalid_address] => Invalid address:
[mailer_not_supported] => mailer is not supported.
[provide_address] => You must provide at least one recipient email address.
[recipients_failed] => SMTP Error: The following recipients failed:
[signing] => Signing Error:
[smtp_connect_failed] => SMTP connect() failed.
[smtp_error] => SMTP server error:
[variable_set] => Cannot set or reset variable:
[extension_missing] => Extension missing:
)
[error_count:protected] => 2
[sign_cert_file:protected] =>
[sign_key_file:protected] =>
[sign_extracerts_file:protected] =>
[sign_key_pass:protected] =>
[exceptions:protected] => 1
[uniqueid:protected] => 1d6e4a91953547c850de852e798ccbba
)
Heading
Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array (
)
Connection: Failed to connect to server.
Error number 2. "Error notice: stream_socket_client():
SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failedConnection: Failed to connect to server.
Error number 2. "Error notice: stream_socket_client(): Failed to enable cryptoConnection: Failed to connect to server.
Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error)
SMTP ERROR: Failed to connect to server: (0)SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Try this plugin https://wordpress.org/plugins/blastex and send email without local smtp server !
Probably self signed certificate on smtp server !!!

How to connect external database at run time in custom module drupal 8

I am a drupal8 developer. I want to connect to other external database in module. Likewise in D7 it's something like this:
$other_database = array(
'database' => 'databasename',
'username' => 'username', // assuming this is necessary
'password' => 'password', // assuming this is necessary
'host' => 'localhost', // assumes localhost
'driver' => 'mysql', // replace with your database driver
);
// replace 'YourDatabaseKey' with something that's unique to your module
Database::addConnectionInfo('YourDatabaseKey', 'default', $other_database);
db_set_active('YourDatabaseKey');
// execute queries here
db_set_active(); // without the paramater means set back to the default for the site
drupal_set_message(t('The queries have been made.'));
I tried this in D8 but it's throwing an error. Can you help me in this regard?
After connecting to the external DB you should clear your cache pragmatically.
Below is the code snippet:
$database = array(
'database' => <your_database_name>,
'username' => <your_username>,
'password' => <your_password>,
'host' => <host>,
'driver' => 'mysql',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql'
);
\Drupal\Core\Database\Database::addConnectionInfo('<your_key>', 'default', $database);
db_set_active('<your_key>');
drupal_flush_all_caches();
You can use db_set_sctive method in drupal 8 like this
\Drupal::Database->setActiveConnection($key)

How use session authentication in drupal Services module

I have Drupal 7 and Services 3.x (3.10).
In the /admin/structure/services page, i have create an endpoint and my custom module:
function webServices_services_resources() {
$api = array(
'customers' => array(
'retrieve' => array(
'help' => 'Retrieves posted blogs',
'callback' => '_webServices_retrieve',
'access arguments' => array('access content'),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'id',
'type' => 'int',
'description' => 'The id of the note to get',
'source' => array('path' => '0'),
'optional' => FALSE,
),
),
),
),
);
return $api;
}
Now i make a POST request to my base_url/endpoint/user/login.json (passing username and password) and i get the session_name and session_id.
if i call (for example) base_url/endpoint/customers/1.json with the following header:
User-Agent: Fiddler
Content-Type: application/json
Host: liburna3.alpha-si.org
Cookie: SESS738851ba4e98ab1f17a7252513dc0719=hy5xVjlDzjIbXz-nlwEV4GywbAPAPL0d_aFGhtIRWzw
i get error 403: Access denied for user xxxxxxxxx
What is the problem?
I would check my authentication state calling base_url/endpoint/system/connect.
If you are not logged in (or you header is not right) it returns:
"sessid": "PfG79I6elMMYln8nyftReLOY0d5So7O0C3LRIdbOeMo",
"session_name": "SESS74282c529439441e18b575b0e6fe308f",
"user": {
"uid": 0,
"hostname": "2a02:8388:1580:2500:7b:3322:23a4:c902",
"roles": {
"1": "anonymous user"
},
"cache": 0,
"timestamp": 1460891635
}
}
If you are logged in it returns the full userdatat in user property of result.
I setup a testing site for nearly all drupal services calls .>You can enter basepath and endpoint and test you backend.
Find it here => http://www.drupalionic.org/explore/
Enter you data and then go to Resources -> Services 3.x -> System and click the Connect tab.
You can also find a fully featured angular lib for drupal services here => https://github.com/BioPhoton/ng-drupal-7-services

Resources