email working on local server but not working on live server AWS using zf3 - zend-framework3

Description: sending mail from localhost mail working but sending from AWS server mail not working giving error below as i mentioned.
Code:
$options = new SmtpOptions();
$options->setHost('smtp.gmail.com')
->setName('smtp.gmail.com')
->setPort(587)
->setConnectionClass('login')
->setConnectionConfig(array(
'username' => 'user#domain.com',
'password' => '123456789',
'ssl' => 'tls',
'host'=>'333.333.333.333',
'use_complete_quit' => false,
)
);
$transport->setOptions($options);
$res = $transport->send($message);
Error:
An error occurred
An error occurred during execution; please try again later.
Additional information:
Zend\Mail\Protocol\Exception\RuntimeException
File:
/var/www/vendor/zendframework/zend-mail/src/Protocol/AbstractProtocol.php:348
Message:
5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuo
5.7.14 Px2wvtfOrS5wFFQmXT6hEwb6_1qcc1hT6WbEWXyUx_ySCaHzuDAWuVXje2HQlktgHPhwIi
5.7.14 8qrKNzgRYBckbmSR5J6_w5JDU5MJHcE-dHh718s0BTmxnsRPpHm970TwgImXzT> Please
5.7.14 log in via your web browser and then try again.
5.7.14 Learn more at
5.7.14 https://support.google.com/mail/answer/78754 a9sm10567779iod.76 - gsmtp
Stack trace:
#0 /var/www/vendor/zendframework/zend-mail/src/Protocol/Smtp/Auth/Login.php(78): Zend\Mail\Protocol\AbstractProtocol->_expect(Array)
#1 /var/www/vendor/zendframework/zend-mail/src/Protocol/Smtp.php(222): Zend\Mail\Protocol\Smtp\Auth\Login->auth()
#2 /var/www/vendor/zendframework/zend-mail/src/Transport/Smtp.php(401): Zend\Mail\Protocol\Smtp->helo('smtp.gmail.com')
#3 /var/www/vendor/zendframework/zend-mail/src/Transport/Smtp.php(383): Zend\Mail\Transport\Smtp->connect()
#4 /var/www/vendor/zendframework/zend-mail/src/Transport/Smtp.php(394): Zend\Mail\Transport\Smtp->lazyLoadConnection()
#5 /var/www/vendor/zendframework/zend-mail/src/Transport/Smtp.php(251): Zend\Mail\Transport\Smtp->connect()
#6 /var/www/module/Application/src/Controller/PurchaseController.php(785): Zend\Mail\Transport\Smtp->send(Object(Zend\Mail\Message))
#7 /var/www/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Application\Controller\PurchaseController->orderPlaceAction()
#8 /var/www/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#9 /var/www/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 /var/www/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(106): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#11 /var/www/vendor/zendframework/zend-mvc/src/DispatchListener.php(138): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#12 /var/www/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#13 /var/www/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#14 /var/www/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#15 /var/www/html/index.php(54): Zend\Mvc\Application->run()
#16 {main}

Well if you check the support page for error code 78754 of google, they mentions few possible problems.
If you're sure about your mail and password, please be sure you don't request too frequently. They says you shouldn't make request more than 10 minutes.
Also if you're using 2-steps verification, you will need to create application based password or you'll have to use oAuth to access gmail.
I suggest you read this this article too.

Related

How to store DateTime using cloud function in cloud firestore?

I am trying to store DateTime using cloud function. I sent this from client side.
taskData: {
'dueDateTime': dateTime,
'nullDueDate': false,
'willNotify': false,
'notificationDateTime': null,
},
And this is how sent the data to cloud function.
HttpsCallable callable =
FirebaseFunctions.instance.httpsCallable('updateTask');
await callable.call({
'taskID': taskID,
'authorID': authorID,
'users': users,
'taskData': taskData,
});
I am getting error and it's thrown from flutter side, I am not getting any error from cloud function.
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: 'package:cloud_functions/src/https_callable.dart': Failed assertion: line 55 pos 10: 'parameter == null ||
parameter is String ||
parameter is num ||
parameter is bool': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 _assertValidParameterType
package:cloud_functions/src/https_callable.dart:55
#3 _assertValidParameterType.<anonymous closure>
package:cloud_functions/src/https_callable.dart:52
Reloaded 0 of 1208 libraries in 133ms.
Reloaded 33 of 1208 libraries in 791ms.
Reloaded 40 of 1208 libraries in 758ms.
Reloaded 40 of 1208 libraries in 695ms.
#4 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#5 _assertValidParameterType
package:cloud_functions/src/https_callable.dart:52
#6 _assertValidParameterType.<anonymous closure>
package:cloud_functions/src/https_callable.dart:52
#7 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#8 _assertValidParameterType (pac<…>
It not necessary since no error on cloud function but here is my Type Script code. If it comment the //'dueDateTime': dateTime, then I have no issue.
const taskData = data['taskData'];
batch.update(userAssignedTaskPath, taskData);
When I used client side code to update firestore it converted DateTime to Timestamp and everything worked fine. I even tried to convert DateTime to Timestamp and sent it to the function Timestamp.fromDate(dateTime) but didn't work.
Updated on 9 Jan 21: I found the solution here. If you wanna see the code let me know I will post. Convert date to timestamp for storing into firebase firestore in javascript
I would recommend to convert this into a string with .toIso8601String()
To get it back from Firestore, use DateTime.parse(snap.data()['myDate']),

Not able to connect Firebase with php

I am using firebase as backend in php, but when i am calling "fromJsonFile" method of "ServiceAccount" i am getting bellow error:
Fatal error: Uncaught Error: Call to private method
Kreait\Firebase\ServiceAccount::fromJsonFile() from context '' in
C:\xampp\htdocs\wordpress\wp-content\plugins\firebase-connection.php:7
Stack trace: #0 C:\xampp\htdocs\wordpress\wp-content\plugins\sb-api\sb_api.php(31):
include() #1 C:\xampp\htdocs\wordpress\wp-settings.php(362):
include_once('C:\xampp\htdocs...') #2
C:\xampp\htdocs\wordpress\wp-config.php(90):
require_once('C:\xampp\htdocs...') #3
C:\xampp\htdocs\wordpress\wp-load.php(37):
require_once('C:\xampp\htdocs...') #4
C:\xampp\htdocs\wordpress\wp-admin\admin.php(34):
require_once('C:\xampp\htdocs...') #5
C:\xampp\htdocs\wordpress\wp-admin\index.php(10):
require_once('C:\xampp\htdocs...') #6 {main}
thrown in C:\xampp\htdocs\wordpress\wp-content\plugins\firebase-connection.php
on line 7
The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.
Here is my code:
<?php
require __DIR__.'/vendor/autoload.php';
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/google-service-account.json');
$firebase = (new Factory)
->withServiceAccount($serviceAccount)
->create();
$database = $firebase->getDatabase();
?>
Can you tell us the version of the firebase-php that you are currently using?
If you are using version lower than 5.x please update to the latest version.
https://github.com/kreait/firebase-php
It is using php 7.2^. Current wordpress requires 7.3 so it must be updated to latest version
Here is the documentation as well.
https://firebase-php.readthedocs.io/en/latest/
I don't know exactly what the problem is but it seems the error says you can't access a private method, so you should access it by updating it to public or public static method.
For ver 5.x
// #see https://firebase-php.readthedocs.io/en/5.2.0/troubleshooting.html
$factory = (new Factory)->withServiceAccount(__DIR__.'/google-service-account.json');
$database = $factory->createDatabase();
// if you want auth
//$auth = $factory->createAuth();

WSO2 3 : Error while generating PRODUCTION token for application

I was able to get past invalid_callback error. Ref: Wso2 apiman: INVALID REQUEST, invalid_callback
However, I'm not able to generate tokens for api. Any workaround is much appreciated.
Caused by: javax.net.ssl.SSLException: hostname in certificate didn't match: localhost != dev.org
2020-03-01T12:06:46,418 [-] [https-jsse-nio-9443-exec-40] ERROR APIConsumerImpl Error while re-generating AccessToken
org.wso2.carbon.apimgt.api.APIManagementException: Error while creating tokens - hostname in certificate didn't match: localhost != dev.org
Any other changes to be made?
The workaround for "Error generating PRODUCTION token" is :
Un-comment section [apim.oauth_config] 'revoke_endpoint' lines as
shown below.
Replace
Change this : revoke_endpoint = "https://localhost:${https.nio.port}/revoke"
To :revoke_endpoint = "https://dev.apigw.org:${https.nio.port}/revoke"
[apim.oauth_config]
#enable_outbound_auth_header = false
#auth_header = "Authorization"
revoke_endpoint = "https://dev.apigw.org:${https.nio.port}/revoke"
#enable_token_encryption = false
#enable_token_hashing = false
One other approach you can follow is adding localhost as a SAN when you generate the new certificate/keystore.

Httpclient Xamarin Forms call not working in Android

I am having a strange problem that occurs when debugging the xamarin forms app in android physical device.
The app goes to break mode and here is the output i receive:
Mono.Android[0xd6be8960] -> System[0xd6be9680]: 14
11-24 23:44:44.098 I/Choreographer(18685): Skipped 930 frames! The application may be doing too much work on its main thread.
Thread started: <Thread Pool> #8
Thread started: <Thread Pool> #9
11-24 23:44:44.807 D/Mono (18685): Assembly Ref addref Mono.Security[0xc17989e0] -> System[0xd6be9680]: 15
Thread started: <Thread Pool> #10
An unhandled exception occured.
I tried many solutions such as allowing the network access in the app, made sure that the all needed packages are there such as:
Microsoft.Bcl.Build
Microsoft.net.HTTP
Newtonsoft.json
This is my code which works fine in UWP
var request = new HttpRequestMessage();
request.RequestUri = new Uri("https://jsonplaceholder.typicode.com/users");
request.Method = HttpMethod.Get;
request.Headers.Add("Accept", "application/json");
var client = new HttpClient();
HttpResponseMessage response = await client.SendAsync(request);
HttpContent content = response.Content;
var statusCode = response.StatusCode;
var json = await content.ReadAsStringAsync();
EDIT: I am getting 2 main errors in the device log:
[ERROR] FATAL UNHANDED EXCEPTION: System.Net.HttpRequestException:An error occurred while sending the request --> System.Net.WebException:Error:SecureChannelFailure(The authentication or decryption has failed)
Change the default SSL/TLS implementation in Xamarin.Android.
Go to Android Project settings->Android Options->Advanced->SSL/TLS implementation and set it to Native TLS 1.2+
On some Cases you need to chagne the HttpClient Implementation to be AndroidClientHandler instead of Default as the following:

ODBC connection on a wordpress site

I am trying to make a localhosted WordPress site use the ODBC connections I use for business analytics.
I made a plugin and am trying to reference the functions in shortcode (because this is the only way I know to do this).
Below is my code:
$dsn = '****';
$user = '****';
$pw = '****';
$connect = odbc_connect($dsn, $user, $pw);
if ($connect == true){
echo '<br> connected <br>';
} else{
echo '<br> not connected <br>';
}
From what I understand this should be testing to see if the connection is open and it gives me an error (posted below). My big question is if I need to install an ODBC driver on the site to make it able to perform the connection.
If so, where do I find this?
I use four MS SQL servers on the domain and would also like to be able to work with access and excel.
Fatal error: Uncaught Error: Call to undefined function odbc_connect()
in
C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-content\plugins\HPM-custom\HPM.php:54
Stack trace:
#0 C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-includes\shortcodes.php(326):HPM_API_E2('', '', 'HPM_API_E2')
#1 [internal function]: do_shortcode_tag(Array)
#2 C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-includes\shortcodes.php(223):preg_replace_callback('/\\[(\\[?)(HPM_AP...','do_shortcode_ta...','[HPM_API_E2]\n[H...')
#3 C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-includes\plugin.php(235):do_shortcode('[HPM_API_E2]\n[H...')
#4 C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-includes\post-template.php(240):apply_filters('the_content', '[HPM_API_E2]\n[H...')
#5 C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-content\themes\generatepress\content-page.php(24):the_content()
#6 C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-includes\template.php(574):require('C:\\Bitnami\\word...')
#7 C:\Bitnam in C:\Bitnami\wordpress-4.5.3-1\apps\wordpress\htdocs\wp-content\plugins\HPM-custom\HPM.php on line 54
$connect will never be true. This is because odbc_connect() does not return a boolean when it succeeds. It returns a connection IDinstead.
If the connection fails it will return an error or false, so it will end up in the else. If it succeeds it contains an ID and should evaluate to true.
if ($connect){
echo '<br> connected <br>';
} else{
echo '<br> not connected <br>';
}
Edit:
You've just added the error message you're getting. That error means the function is not available, and that will most likely be caused by the missing ODBC drivers for your php client. Someone else made this post on how to install this:
Call to undefined function odbc_connect() message while connecting SAP Hana database
I hope this helps.

Resources