I want to change env configuration from Controller, but this didnt work.
Controller
config(['MAIL_HOST' => 'smtp.sendgrid.net']);
config(['MAIL_PORT' => '25']);
config(['MAIL_USERNAME' => 'apikey']);
config(['MAIL_PASSWORD' => 'SG..']);
Mail::send(
'vendor.maileclipse.templates.news',
["content" => $content],
function ($message) use ($email) {
$message->to($email)->subject('Email');
}
);
}
.env
MAIL_DRIVER=smtp
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=xy#xy.com
MAIL_FROM_NAME="Test"
mail.php
You can set like below
config([
'mail.mailers.smtp.host' => '',
'mail.mailers.smtp.port' => ,
'mail.mailers.smtp.encryption' => '',
'mail.mailers.smtp.username' => '',
'mail.mailers.smtp.password' => '',
'mail.from.address' => ''
]
);
This will override from mail.php
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
Note:As infromed by #ceejayoz in comment .Remembe tt should be noted that this will only change it for that request. It will not change it for other requests, and will not update the .env file. –
Updated
config([
'mail.host' => '',
'mail.port' => ,
'mail.encryption' => '',
'mail.username' => '',
'mail.password' => '',
'mail.from.address' => ''
]
);
Use config file keys instead of .env variables, in your case config/mail.php
config(['mail.mailers.smtp.host' => 'smtp.sendgrid.net']);
config(['mail.mailers.smtp.port' => '25']);
config(['mail.mailers.smtp.username' => 'apikey']);
config(['mail.mailers.smtp.password' => 'SG...']);
Mail::send(
'vendor.maileclipse.templates.news',
["content" => $content],
function ($message) use ($email) {
$message->to($email)->subject('Email');
}
);
}
Related
I would like to check if a customer already exists so that I can update his details or if he does not exist create it by starting a new subscription.
I created this, but I believe there is something wrong.
if(Auth::user()->subscribed('default')) {
$stripe->customers->update(Auth::user()->stripe_id, array([
'email' => Auth::user()->email,
'name' => 'Example Example',
'phone' => '322234455556',
'address' => [
'city' => 'Alcatraz',
'line1' => 'Via Dalle Palle',
'postal_code' => '96011',
'state' => 'Italia'
]
]));
} else {
$stripe->customers->create([
'description' => 'Example Example',
'email' => Auth::user()->email,
'name' => 'Example Example',
'phone' => '322234455556',
'address' => [
'city' => 'Alcatraz',
'line1' => 'Via Dalle Palle',
'postal_code' => '96011',
'state' => 'Italia'
]
]);
}
I think there is a mistake, because when I go to create a new subscription with a newly registered user, therefore not present on Stripe as a customer, it does nothing but create me two entries as in the image below.
I solved it this way
$stripeCustomer = Auth::user()->createOrGetStripeCustomer([
'description' => 'Example Example',
'email' => Auth::user()->email,
'name' => 'Example Example',
'phone' => '322234455556',
'address' => [
'city' => 'Alcatraz',
'line1' => 'Via Dalle Palle',
'postal_code' => '96011',
'state' => 'Italia'
]
]);
It showing me this error
Expected response code 250 but got code "530", with the message "530-5.7.0 Authentication Required. Learn more at 530 5.7.0 https://support.google.com/mail/?p=WantAuthError
while I have enabled two-factor authentication and generated an app password.
here is my .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=myAppGeneratedPassword
MAIL_ENCRYPTION=tls
and here is my mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'myemail#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'my_name'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('myemail#gmail.com'),
'password' => env('appPassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/mail'),
],
],
];
Please help me. I am trying for three days.
Can you try with this config
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
After deploy Magento 2 Translation Extension by Magefan i got following error
{"0":"Warning: class_implements(): Class TranslationGridDataProvider does not exist and could not be loaded in \/home\/419982.cloudwaysapps.com\/vftydjkdjd\/public_html\/vendor\/magento\/framework\/Code\/Reader\/ClassReader.php on line 71","1":"<pre>#1 class_implements('TranslationGridD...') called at [vendor\/magento\/framework\/Code\/Reader\/ClassReader.php:71]\n#2 Magento\\Framework\\Code\\Reader\\ClassReader->getParents('TranslationGridD...') called at [vendor\/magento\/framework\/View\/Element\/UiComponent\/Argument\/Interpreter\/ConfigurableObject.php:118]\n#3 Magento\\Framework\\View\\Element\\UiComponent\\Argument\\Interpreter\\ConfigurableObject->getParents('TranslationGridD...') called at [vendor\/magento\/framework\/View\/Element\/UiComponent\/Argument\/Interpreter\/ConfigurableObject.php:96]\n#4 Magento\\Framework\\View\\Element\\UiComponent\\Argument\\Interpreter\\ConfigurableObject->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [generated\/code\/Magento\/Framework\/Data\/Argument\/InterpreterInterface\/Proxy.php:95]\n#5 Magento\\Framework\\Data\\Argument\\InterpreterInterface\\Proxy->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [vendor\/magento\/framework\/Data\/Argument\/Interpreter\/Composite.php:61]\n#6 Magento\\Framework\\Data\\Argument\\Interpreter\\Composite->evaluate(array('name' => 'dataProvider', 'argument' => array('class' => array('name' => 'class', 'xsi:type' => 'string', 'value' => 'TranslationGridD...'), 'name' => array('name' => 'name', 'xsi:type' => 'string', 'value' => 'translation_tran...'), 'primaryFieldName' => array('name' => 'primaryFieldName', 'xsi:type' => 'string', 'value' => 'key_id'), 'requestFieldName' => array('name' => 'requestFieldName', 'xsi:type' => 'string', 'value' => 'id'), 'data' => array('name' => 'data', 'xsi:type' => 'array', 'item' => array('config' => array('name' => 'config', 'xsi:type' => 'array', 'item' => array('component' => array('name' => 'component', 'xsi:type' => 'string', 'value' => 'Magento_Ui\/js\/gr...'), 'update_url' => array('name' => 'update_url', 'xsi:type' => 'url', 'path' => 'mui\/index\/render'), 'storageConfig' => array('name' => 'storageConfig', 'xsi:type' => 'array', 'item' => array('indexField' => array('name' => 'indexField', 'xsi:type' => 'string', 'value' => 'key_id')))))))))) called at [vendor\/magento\/module-ui\/Config\/Data.php:164]\n#7 Magento\\Ui\\Config\\Data-
Please make sure that when installing Magento 2 Translation Extension you followed the installation instructions, especially the step
php bin/magento setup:di:compile
Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required.
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME="username#gmail.com"
MAIL_PASSWORD="password"
MAIL_ENCRYPTION=tls
config/mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'username#gmail.com', 'name' => 'Name'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('username'),
'password' => env('password'),
'sendmail' => '/usr/sbin/sendmail -bs',
'username' => env('username')
'password' => env('password')
Should be:
'username' => env('MAIL_USERNAME')
'password' => env('MAIL_PASSWORD')
I started a project with Zend Framework 2 and I set up the modules ZfcUser and BjyAuthorize.
The ZfcUser part works correctly but when I active BjyAuthorize an error occurs
Doctrine\ORM\EntityNotFoundException: Entity was not found. in /vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php on line 177
Call Stack
here is my config file :
- comper.json
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.3.*",
"zf-commons/zfc-user": "dev-master",
"zendframework/zftool": "dev-master",
"doctrine/doctrine-orm-module": "0.8.0",
"gedmo/doctrine-extensions": "v2.3.9",
"zendframework/zend-developer-tools": "dev-master",
"zf-commons/zfc-user-doctrine-orm": "dev-master",
"zf-commons/zfc-admin": "dev-master",
"bjyoungblood/bjy-authorize": "1.4.0"
}
}
application.config.php
return array(
'modules' => array(
'ZendDeveloperTools',
'ZfcAdmin',
'DoctrineModule',
'DoctrineORMModule',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineORM',
'BjyAuthorize',
'Application',
'Fountain',
'Rest',
),
'module_listener_options' => array(
'module_paths' => array(
'./module',
'./vendor',
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
),
);
bjyauthorize.global.php
return array(
'bjyauthorize' => array(
'default_role' => 'guest',
'identity_provider' => 'BjyAuthorize\Provider\Identity\ZfcUserZendDb',
'role_providers' => array(
'BjyAuthorize\Provider\Role\Config' => array(
'guest' => array(),
'user' => array('children' => array(
'admin' => array(),
)),
),
'BjyAuthorize\Provider\Role\ZendDb' => array(
'table' => 'role',
'identifier_field_name' => 'id',
'role_id_field' => 'roleId',
'parent_role_field' => 'parent_id',
),
'BjyAuthorize\Provider\Role\ObjectRepositoryProvider' => array(
'role_entity_class' => 'Fountain\Entity\Role',
'object_manager' => 'doctrine.entitymanager.orm_default',
),
),
'resource_providers' => array(
'BjyAuthorize\Provider\Resource\Config' => array(
'pants' => array(),
),
),
'rule_providers' => array(
'BjyAuthorize\Provider\Rule\Config' => array(
'allow' => array(
array(array('guest', 'user'), 'pants', 'wear')
),
'deny' => array(
// ...
),
),
),
'guards' => array(
'BjyAuthorize\Guard\Controller' => array(
array('controller' => 'index', 'action' => 'index', 'roles' => array('guest','user')),
array('controller' => 'index', 'action' => 'stuff', 'roles' => array('user')),
array(
'controller' => array('index', 'static', 'console'),
'action' => array('list', 'manage'),
'roles' => array('guest', 'admin')
),
array(
'controller' => array('search', 'administration'),
'roles' => array('staffer', 'admin')
),
array('controller' => 'zfcuser', 'roles' => array()),
),
'BjyAuthorize\Guard\Route' => array(
array('route' => 'zfcuser', 'roles' => array('user')),
array('route' => 'zfcuser/logout', 'roles' => array('user')),
array('route' => 'zfcuser/login', 'roles' => array('guest')),
array('route' => 'zfcuser/register', 'roles' => array('guest')),
// Below is the default index action used by the ZendSkeletonApplication
array('route' => 'home', 'roles' => array('guest', 'user')),
array('route' => 'home', 'roles' => array('guest', 'user', 'admin')),
array('route' => 'fountain', 'roles' => array('guest', 'user')),
array('route' => 'fountain/add', 'roles' => array( 'admin')),
array('route' => 'fountain/delete', 'roles' => array('admin')),
array('route' => 'fountain/edit', 'roles' => array('admin')),
),
),
),
);
zfcuserdoctrineorm.global.php
return array(
'doctrine' => array(
'driver' => array(
// overriding zfc-user-doctrine-orm's config
'zfcuser_entity' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'paths' => array( __DIR__ .'/../../module/Fountain/src/Fountain/Entity'),
),
'orm_default' => array(
'drivers' => array(
'Fountain\Entity' => 'zfcuser_entity',
),
),
),
),
'zfcuser' => array(
// telling ZfcUser to use our own class
'user_entity_class' => 'Fountain\Entity\User',
'enable_default_entities' => false,
),
);
Anyone have an idea of the origin of this problem?