I need to send a few mails with my laravel application, and they are not really personalized. I've used the markdown mail system in laravel, and everything was smooth for the tests. I had mailtrap setup to catch all the mails, no problems.
Now I have to use mailjet to send mails - not to create emails and everything, just to have an adress to send them and a way to know where they did go. I've installed the laravel-mailjet package, I've done everything in the doc (except the last part, my mails already work), but no luck, nothing works. I don't have any error in the logs, I don't have any error when the mail is supposed to be thrown, it just kinda don't try to send the mail at all. I've tried on local and prod (I was thinking that maybe it was because of the dns), everything is perfectly setup between my dns and mailjet, but I can't launch any mail and google is no help on this one.
.env
MAIL_MAILER=mailjet
MAIL_HOST=in-v3.mailjet.com
MAIL_PORT=587
MAIL_USERNAME={api key}
MAIL_PASSWORD={api secret}
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS={mail}
MAIL_FROM_NAME="${APP_NAME}"
MAILJET_APIKEY={api key}
MAILJET_APISECRET={api secret}
app.php
'providers' => [
...
Mailjet\LaravelMailjet\MailjetServiceProvider::class,
Mailjet\LaravelMailjet\MailjetMailServiceProvider::class,
],
'aliases' => [
...
'Mailjet' => Mailjet\LaravelMailjet\Facades\Mailjet::class,
],
mail.php
'mailers' => [
....
'mailjet' => [
'transport' => 'mailjet',
],
],
services.php
'mailjet' => [
'key' => env('MAILJET_APIKEY'),
'secret' => env('MAILJET_APISECRET'),
'transactional' => [
'call' => true,
'options' => [
'url' => 'api.mailjet.com',
'version' => 'v3.1',
'call' => true,
'secured' => true
]
],
'common' => [
'call' => true,
'options' => [
'url' => 'api.mailjet.com',
'version' => 'v3',
'call' => true,
'secured' => true
]
],
'v4' => [
'call' => true,
'options' => [
'url' => 'api.mailjet.com',
'version' => 'v4',
'call' => true,
'secured' => true
]
],
]
I've tried to erase all my modifications and just let the .env, with no luck too. What am I missing?
Ok, found my problem. The whole setup was good, it was in the Mailable class that I was missing something; the mail used to send the confirmation wasn't register in Mailjet. Just a modification in the ->from(email) in the class and everything works now.
It's just weird that I couldn't get any error message that could give me clue on what was going on, no error in logs and no error on Mailjet.
Related
I have installed the Rollbar 7.0 into Laravel 8.0. PHP version is 7.4
I am trying to send a test exception message using a simple Console command but that sends me nothing.
My configs are the following:
config/app.php:
return [
'providers' => [
Rollbar\Laravel\RollbarServiceProvider::class
...
]
config/logging.php:
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['other', 'rollbar'],
'ignore_exceptions' => false,
],
'rollbar' => [
'driver' => 'monolog',
'handler' => MonologHandler::class,
'access_token' => env('ROLLBAR_TOKEN'),
'level' => env('ROLLBAR_LEVEL'),
'enabled' => true,
'environment' => env('ROLLBAR_ENVIRONMENT'),
]
....
config/services.php (but seems to be that it doesn't work)
'rollbar' => [
'access_token' => env('ROLLBAR_TOKEN'),
'environment' => env('ROLLBAR_ENVIRONMENT'),
'level' => env('ROLLBAR_LEVEL')
],
app.env:
ROLLBAR_TOKEN=real_token
ROLLBAR_LEVEL=debug
ROLLBAR_ENVIRONMENT=backend_test
And the console command itself has the following view:
public function handle()
{
// Rollbar::init([
// 'driver' => 'monolog',
// 'handler' => MonologHandler::class,
// 'access_token' => env('ROLLBAR_TOKEN'),
// 'level' => env('ROLLBAR_LEVEL'),
// 'enabled' => true,
// 'environment' => env('ROLLBAR_ENVIRONMENT'),
// ]);
try{
$x = 4/0;
} catch(\Exception $exception) {
Rollbar::error('caught demo exception', ["details" => $exception->getMessage()]));
Rollbar::flush();
exit(1);
}
}
So when it is like this, the rollbar stays silent. But if I uncomment the initialisation, that works well, sending a debug message to the rollbar.
That doesn't work all over the project too.
Could you please advice me, what could I do here in order to make it work globally with initialising in every file?
upd: I've also cleared config cache and tried to make a rollbar as a default
Laravel in app/logging.php has a default channel configuration. Normally "default" should mean that there are some other working channel too but here, somehow it the meaning is like "the only used channel". Or I just do not fully understand how should it work. So my rollbar channel seems to be overriden by the another "default" one, that is why the system doesn't use it. So the solution is to switch the default channel:
'default' => env('LOG_CHANNEL', 'stack'),
when the rollbar is included to stack channel or just
'default' => env('LOG_CHANNEL', 'rollbar'),
when it is not.
So I'm using beyondcode/laravel-websockets to setup a WS server and I want to work with multiple apps so I did this in config\websockets.php:
'apps' => [
[
'id' => env('A_APP_ID'),
'name' => env('A_APP_NAME'),
'key' => env('A_APP_KEY'),
'secret' => env('A_APP_SECRET'),
'path' => env('A_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
[
'id' => env('B_APP_ID'),
'name' => env('B_APP_NAME'),
'key' => env('B_APP_KEY'),
'secret' => env('B_APP_SECRET'),
'path' => env('B_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
],
However, I want to implement custom handlers for each app and I've been trying this, routes\web.php:
WebSocketsRouter::webSocket('app/{appKey}/bapp', \App\WebSockets\BAppWebSocketHandler::class);
//Also tried this..
WebSocketsRouter::webSocket('app/{appKey}', \App\WebSockets\AAppWebSocketHandler::class);
//and created `AAppWebSocketHandler` which does nothing but calling parent (WebSocketHandler) methods
Problem is it's always using one handler for all apps despite the difference in routes.
Any ideas?
Thanks!
You don't have to define routes while defining multiple apps in the config. Instead configure Echo to work with separate app key and secret. If you want to use custom handler with own logic, then remove them from configs. Also note that, you won't get any channel or pusher client library support. You will have to implement your own authentication as well.
I have a Laravel 5.6 project and I want to configure it such that high level errors are emailed to me.
I have added an email channel to logging.php config file and specified Monolog's Swiftmailer as the handler but since it needs a mailer instance and message in its constructor I don't know what values should be supplied.
Any help is much appreciated.
PS: I do know there are packages for this purpose but think this should be simple enough to do manually.
'email' => [
'driver' => 'monolog',
'handler' => Monolog\Handler\SwiftMailerHandler::class,
'handler_with' => [
'mailer' => ?,
'message' => ?,
],
],
With Lavarel 7.x you can solve it like this
'smtp-sys' => [
'driver' => 'monolog',
'level' => 'info',
'handler' => SwiftMailerHandler::class,
'handler_with' => [
'mailer' => new Swift_Mailer( (new Swift_SmtpTransport(env('MAIL_HOST_SYS'), env('MAIL_PORT_SYS'), env('MAIL_ENCRYPTION', 'tls')))->setUsername(env('MAIL_USERNAME_SYS'))->setPassword(env('MAIL_PASSWORD_SYS'))),
'message' => (new Swift_Message('[LOG] Exception'))
->setFrom([env('MAIL_USERNAME_SYS') => 'Dev'])
->setTo([env('MAIL_USERNAME_SYS') => 'Dev'])
],
],
It might be a little late but from Symfony SwiftMailer documentation you should use something like this:
...
'email' => [
'driver' => 'monolog',
'level' => 'critical',
'handler' => SwiftMailerHandler::class,
'handler_with' => [
'mailer' => (new Swift_SmtpTransport(env('MAIL_HOST'), env('MAIL_PORT'), env('MAIL_ENCRYPTION')))
->setUsername(env('MAIL_USERNAME'))
->setPassword(env('MAIL_PASSWORD')),
'message' => (new Swift_Message('[LOG] Exception'))
->setFrom([env('LOG_MAIL_FROM_ADDRESS') => env('LOG_MAIL_FROM_NAME')])
->setTo([env('LOG_MAIL_TO_ADDRESS') => 'Dev'])
->setBody('Here is the message itself')
],
'formatter' => HtmlFormatter::class,
],
...
I am trying to use EAuth extension in Yii2 advanced application. I installed it through composer and it installed it under vendor directory and configured as mentioned here (did the config in common/config/main). So, following is the directory structure for that:
root
vendor
nodege
lightopenid
provider
*files go here*
yii2-eauth
src
*files go here*
EAuth.php is under src folder. In controller I have done this in use:
use nodge\eauth\EAuth;
and when I do this:
$eauth = Yii::$app->get('eauth')->getIdentity($serviceName);
I get the following error:
Class nodge\eauth\EAuth does not exist
What am I doing wrong? Any help?
Update:
This is my config:
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'eauth' => [
'class' => 'nodge\eauth\EAuth',
'popup' => true, // Use the popup window instead of redirecting.
'cache' => false, // Cache component name or false to disable cache. Defaults to 'cache' on production environments.
'cacheExpire' => 0, // Cache lifetime. Defaults to 0 - means unlimited.
'httpClient' => [
// uncomment this to use streams in safe_mode
//'useStreamsFallback' => true,
],
'services' => [// You can change the providers and their classes.
'google' => [
// register your app here: https://code.google.com/apis/console/
'class' => 'nodge\eauth\services\GoogleOAuth2Service',
'clientId' => '...',
'clientSecret' => '...',
'title' => 'Google',
],
'facebook' => [
// register your app here: https://developers.facebook.com/apps/
'class' => 'nodge\eauth\services\FacebookOAuth2Service',
'clientId' => '---',
'clientSecret' => '---',
],
'yahoo' => [
'class' => 'nodge\eauth\services\YahooOpenIDService',
//'realm' => '*.example.org', // your domain, can be with wildcard to authenticate on subdomains.
],
],
],
],
I am currently building a second system with yii2. It will use some tables from a Yii1 database for translation. The Yii1 project was originally translated using files but this has now been moved to the db. All the translations of the Yii1 system use one of three categories app,flash,email of which the vast majority use app.
In the Yii2 project I have the following in the web.php config file.
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'cdb',
'sourceMessageTable' => 'translation_source',
'messageTable' => 'translation',
'forceTranslation'=>true,
],
],
],
All of the translations on the system that use app are not translated, however, all other categories are. If I change the above code to
'i18n' => [
'translations' => [
'app*' => [
Then I get an error for other categories but not app and the app strings are translated as expected. The error I get is
Unable to locate message source for category 'flash'.
If however I change my config to the following, this works for all translations.
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'cdb',
'sourceMessageTable' => 'translation_source',
'messageTable' => 'translation',
'forceTranslation' => true,
],
'app*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'cdb',
'sourceMessageTable'=>'translation_source',
'messageTable' => 'translation',
'forceTranslation' => true,
],
],
],
It just seems odd that I am having to include effectively the same code block twice. Can anyone tell me how I can achieve this in one array or is this the expected behaviour?
** Update **
I do see some mention of * in the docs Docs. I also see some mention of this in the Forum