How do i add Mailgun variables into a template? - codeigniter

I've just started using mailgun, and i've created a template on their dashboard.
In my codeigniter project i've added the following code :
$this->mailgun::send([
'from' => "ZooTopia <no-reply#zoop.com>",
'to' => "XXXXXXX#gmail.com",
'subject' => "Welcome to BB.com",
'text' => "We just want to say hi. Have fun at Example.com",
'template' => "test",
'v:name' => "Jamie"
]);
I want to be able to display the variable for name onto the transactional email template i've created on the mailgun site.
I tried %name% but that doesn't seem to work.
any ideas?

What is your template code?
try to use {{name}} instead of %name%
Mailgun is using https://handlebarsjs.com/ for templates
also try to replace
'v:name' => "Jamie"
to:
'h:X-Mailgun-Variables' => '{"name": "Jamie"}'

Related

How to start using Slug URLs without breaking old in Yii2

i want to rewrite my URLs from
/view?id=100
to
/view/100-article-title
But the site already has several thousand search pages. As far as I know, such a change can be bad for SEO. Is there a way to keep the old URLs working when switching to the new routing.
*I am creating links as follows:
Url::to(['view', 'id' => $item->id])
Is it possible to create links further through ID?
you can create getLink() function on your model and use it on. Then, when function runs you can check id if id <= 100 then return Url::to(['view', 'id' => $item->id]) else return Url::to(['view', 'id' => $item->id, 'slug' => $this->slug])
And add route with slug on your main.php
Look at my example.
First config urlManager in config.php in 'app/config' folder. In my case look like:
'components' => [
...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
''=>'home/index',
'<slugm>-<id:\d+>-' => 'home/view',
],
],
.
...
],
and create link as fallow:
Url::to(['/home/view', 'id' => $model->home_id, 'slugm' =>$model->title_sr_latn])
and finaly url look like:
https://primer.izrada-sajta.rs/usluge-izrade-sajtova-1-

Laravel socialite dynamic redirectUrl not working in multi-tenant app

i have a multi-tenant app and i am trying to add Facebook linking in it i have tried the process using laravel socialite but i have a problem that when i use dynamic redirect url like so
return Socialite::driver('facebook')
->with([
'redirect_uri' => "https://" . $dynamichost . "/social/facebook/callback",
])
->redirect();
or this way
return Socialite::driver('facebook')->redirectUrl('https://' . $dynamichost .
'/social/facebook/callback')->redirect();
facebook returns error url mismatch. Note i also have set a value for redirect_url in .env
then i have services values like this
'facebook' => [
'client_id' => env('FACEBOOK_APP_ID'),
'client_secret' => env('FACEBOOK_APP_SECRET'),
'redirect' => env('CALLBACK_URL_FACEBOOK'),
'default_graph_ve`enter code here`rsion' => 'v3.3',
],
my guess is socialite somehow set the redirect url equal to the value which is coming from .env and when i change it dynamically it still thinks that url will be like the value of .env and i have tested this scenario the request get success response if keep the redirect url static.
Any suggestions how can i overcome this. thanks.
if you want to use custom redirect-uri dynamic :
use Socialite;
use Laravel\Socialite\Two\FacebookProvider;
$socialite = Socialite::buildProvider(
FacebookProvider::class, [
'client_id' => 'your_id',
'client_secret' => 'your_secret',
'redirect' => 'url',
'default_graph_version' => 'v3.3', //not sure if this needed as far as i know, in socialite the version is defined
]
)->redirect();
well it was dumb mistake i had to match the redirect url in callback handling method. its fixed now thanks.

Change/Rename Controller Name In URL: Yii2

I was looking to change controller name in URL. Which, we can do by renaming the controller name in module. But, Through URL manager if we can do it. It will be better.
Module: user,
Controller: api,
Action: index
Right now,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<controller:(api)>/<action:\w+>/<id:[a-z0-9]+>' => 'user/<controller>/<action>',
'<controller:(api)>/<action>' => 'user/<controller>/<action>',
]
];
And, I can access it through.
http://dev.example.com/api/index
But, I was looking to change it to
http://dev.example.com/world/index
How can I do it? Any help/hint/suggestion is appreciable.
You can create custom url rules by adding items to the rules array.
So, in your case insert this into the rules array
'world/index' => 'api/index'
You can read more about URL rules here.
also you use ControllerMap
it useful when you are using third-party controllers and you do not have control over their class names.
below code in component in main.php in advance or web.php in basic
for example:
'controllerMap' => [
'api' => 'app\controllers\WorldController',
]

Sending Email in Laravel Using Swift Mailer without Gmail

Hello i'm new to laravel and still getting familiar with certain features, i would like to know how i can send an email from my laravel application without using gmail smtp settings. Like the way the mail function works in basic PHP. Is this possible? I have tried googling it but i have been unable to find a solution, they all use gmail.
Go to your app/config/mail.php
change driver, host and from
'driver' => 'mail',
'host' => '',
'from' => array('address' => 'us#example.com', 'name' => 'Laravel'),
or you can set 'from' within
Mail::send('emails.welcome', $data, function($message)
{
$message->from('us#example.com', 'Laravel');
$message->to('foo#example.com')->cc('bar#example.com');
});

CakePHP Observe field for validation check(already exists)

i have already user observe field in cakephp 1.3 Now i want to do the same thing in cakephp 2.0
I have one form.there is a one field named email. When user insert email. onblur there is a popup one message that displays "email already exists" or "right"
for that i have write below code in my projects. the below code is my add file code
<?php $options = array('url' => array( 'controller' => 'users', 'action' => 'is_exist'), 'update' => 'email_exist');
echo $this->ajax->observeField('UserEmailId',array('url' => array( 'controller' => 'users', 'action' => 'is_exist'), 'update' => 'email_exists')); ?>
In my controller i have created one function like
public function is_exist($id = null)
{
$result = "yes";
$this->set('existdata',$result);
}
i have also created is_exists.ctp fiel in view/uers.
i dont know why its not working.
i did the same thing in Cakephp 1.3 and its working file but not in cakephp 2.0
can anyone tell me how i implement this ?
thanks in advance
because ajax helper is not supported in cakephp 2.
you need to learn how to implement it using the js helper
check this link : js helper

Resources