SMTP Time out error - Send email from localhost - cakephp

I tried to send email using Google SMTP from localhost, but I keep getting the SMTP time out. error.
This is my config:
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
// The following keys are used in SMTP transports
'host' => 'tls://smtp.gmail.com',
'port' => 587,
'username' => 'xxxxx#gmail.com',
'password' => 'xxxxxsecret',
'log' => true,
'tls' => true,
'domain' => 'localhost',
],
],
I'm running my app on Wampp server.
Please help me, thank you in advanced!

Using mailtrap, you can test this locally. If this works, then most likely the configuration is incorrect or the email isn't being sent through google mail.
https://mailtrap.io - create account and use for free.
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.mailtrap.io',
'port' => 2525,
'timeout' => 30,
'username' => 'YOUR_USERNAME',
'password' => 'YOUR_PASSWORD',
'client' => null,
'tls' => true,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
You can also change the port from 587 to 465 and check. Allow Google to trust your local email server.

Related

I7m developing a website using CakePHP 3.7. I'm working on localhost and would like to send an email from localhost to gmail, but getting error

I am able to send an email from xampp (Mecury) localhost to localhost. But when I try to send an email from Gmail to the localhost I am not being able to do that.
Our main purpose is to send email from Gmail account to the localhost. How can I do that, Any help can be appreciated.
This is the code in my app.php file:
'EmailTransport' => [
'default' => [
//'className' => MailTransport::class,
'className' => 'Smtp',
/*
* The following keys are used in SMTP transports:
*/
'host' => 'smtp.gmail.com',
'port' => 587,
'timeout' => 30,
'username' => 'my#gmail.com',
'password' => 'secret',
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => ['demotest#localhost.com' => 'demotest'],
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
],

How to use multiple db2 databases in Laravel

Currently i use the package cooperl/laravel-db2 for the database connection. For my project, i should to toggle schema database.
I try this in db2.php :
'connections' => [
'ibmi_1' => [
...
'host' => '***********',
'username' => '***********',
'password' => '***********',
'database' => 'database',
'prefix' => '',
'schema' => 'schema_1',
'port' => *****,
'date_format' => 'Y-m-d H:i:s',
...
],
'ibmi_2' => [
...
'host' => '***********',
'username' => '***********',
'password' => '***********',
'database' => 'database',
'prefix' => '',
'schema' => 'schema_2',
'port' => *****,
...
],
And this in .env
DB_CONNECTION=ibmi_1
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_CONNECTION=ibmi_2
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
But when i try in tinker
DB::connection('ibmi_2')
I have this error
InvalidArgumentException with message 'Database connection [ibmi_2] not configured.'
What is wrong ?
The problem was that the database configuration wasn't in bootstrap/cache/config.php.

Unsupported driver [ ] in laravel

i am facing issue of unsupported driver while hitting my API i have following configurations in my config/database.php
'mysql' => [
'driver' => env('DB_CONNECTION'),
'host' => env('DB_HOST'),
'port' => env('DB_PORT'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
// 'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
and my env file
DB_CONNECTION=mysql
DB_HOST=someURLsomeUrl
DB_PORT=3306
DB_DATABASE=ovadahealth_dev
DB_USERNAME=ovadahealth_user
DB_PASSWORD=password
I have spent an hours in this issue and i cant find out where is the issue when i hit my api in postman it says:
{
"status": false,
"message": "Unsupported driver []"
}
Here your help will be highly appreciated!
use php artisan config:clear to clear your configuration.

Sending email from gmail using CakePHP3, Connection refused

I am having a problem with configuration with CakePHP3 for sending email from my Gmail account. I always get an error Connection refused. I don't know where the problem is. So I hope anyone here has any knowledge about sending emails from my Gmail account.
EDIT: I am using GoDaddy hosting server
Here are my configurations.
'gmail' => [
'host' => '(ssl://)smtp.gmail.com',
'port' => 465,
'username' => 'MyGmail#gmail.com',
'password' => 'pass',
'className' => 'Smtp',
'tls' => true
],
'Email' => [
'gmail' => [
'transport' => 'gmail',
'from' => 'myGmail#gmail.com',
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
],
First update email config in CakePHP
Your Updated config/app.php file should be as :
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
// The following keys are used in SMTP transports
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'username#domain.com',
'password' => 'your_password',
],
],
and now use the mail function of CakePHP Email Function.

Different cakephp datasource for local and live

My MySQL connection details are different for both my local connection and my deployed live hosted. I am using CakePHP 3
At the moment I have to keep changing the default datasource which is not really the best way to do it.
I have not added two datasources but I am not sure how to switch between them?
'Datasources' => [
'development' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => '127.0.0.1',
'port' => '8889',
'username' => 'root',
'password' => 'root',
'database' => 'local',
],
'deployment' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'database' => 'live_database',
],
In boostrap or in App Controller, paste this
if(Configure::read('debug')){
ConnectionManager::config('deployment');
}
this change the default config of database when the debug is true.

Resources