PHP code example of addgod / laravel-mandrill-template
1. Go to this page and download the library: Download addgod/laravel-mandrill-template library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
addgod / laravel-mandrill-template example snippets
use Addgod\MandrillTemplate\Mandrill\Message;
use Addgod\MandrillTemplate\Mandrill\Template;
use Addgod\MandrillTemplate\Mandrill\Recipient;
use Addgod\MandrillTemplate\Mandrill\Attachment;
use Addgod\MandrillTemplate\Mandrill\Recipient\Type;
use Addgod\MandrillTemplate\MandrillTemplateFacade;
$template = new Template('template-name');
$message = new Message();
$message
->setSubject('Subjct')
->setFromEmail('[email protected]')
->setFromName('Example Name')
->setMergeVars(['greeting' => 'Hello to you']);
$message->addRecipient(new Recipient('[email protected]', 'Example Name', Type::TO));
$message->addAttachment(Attachment::createFromFile($file, 'name_of_file');
MandrillTemplateFacade::send($template, $message);
use Addgod\MandrillTemplate\MandrillTemplateChannel;
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [MandrillTemplateChannel::class];
}
use Addgod\MandrillTemplate\MandrillTemplateMessage;
public function toMandrillTemplate($notifiable)
{
return (new MandrillTemplateMessage)
->template('notification')
->from('[email protected]', 'Example dot com')
->to('[email protected]', 'Frank Kornell') // This is an extra to, since the notifiable is also used.
->cc('[email protected]', 'Charlott Kornell')
->bcc('[email protected]', 'Mr admin Dude')
->greeting('Hello there'),
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!')
->salutation('Regards from us.')
->attach($file, 'name_of_file);
}