PHP code example of data33 / laravel-mailgun
1. Go to this page and download the library: Download data33/laravel-mailgun 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/ */
data33 / laravel-mailgun example snippets
Mailgun::send('MAILGUN-URL', 'view', ['viewVariable' => 'value'], function(\Data33\LaravelMailgun\Message $msg){
$msg->setFromAddress('sender@YOUR-DOMAIN', 'Sender Name')
->addToRecipient('RECIPIENT-EMAIL', 'Recipient Name')
->setSubject('Test subject');
});
$mg = new Data33\LaravelMailgun\Transporters\AnlutroCurlTransporter('YOUR-MAILGUN-API-KEY');
$result = $mg->send('MAILGUN-URL', ['html' => '<b>Test</b>', 'text' => 'Test'], function(\Data33\LaravelMailgun\Message $msg){
$msg->setFromAddress('sender@YOUR-DOMAIN', 'Sender Name')
->addToRecipient('RECIPIENT-EMAIL', 'Recipient Name')
->setSubject('Test subject');
});
bash
php artisan vendor:publish --provider="Data33\LaravelMailgun\Providers\MailgunServiceProvider" --tag="config"
diff
$mg = new Data33\LaravelMailgun\Transporters\AnlutroCurlTransporter('YOUR-MAILGUN-API-KEY');
-$result = $mg->send('mydomain.com', ['html' => '<b>Test</b>', 'text' => 'Test'], function(\Data33\LaravelMailgun\Message $msg){
+$result = $mg->send('https://api.mailgun.net/v3/mydomain.com/messages', ['html' => '<b>Test</b>', 'text' => 'Test'], function(\Data33\LaravelMailgun\Message $msg){
$msg->setFromAddress('sender@YOUR-DOMAIN', 'Sender Name')
->addToRecipient('RECIPIENT-EMAIL', 'Recipient Name')
->setSubject('Test subject');
});