PHP code example of coconutcraig / laravel-postmark
1. Go to this page and download the library: Download coconutcraig/laravel-postmark 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/ */
use CraigPaul\Mail\TemplatedMailMessage;
public function toMail($notifiable)
{
return (new TemplatedMailMessage)
->identifier(8675309)
->
use CraigPaul\Mail\TemplatedMailable;
use Illuminate\Support\Facades\Mail;
$mailable = (new TemplatedMailable())
->identifier(8675309)
->
use Symfony\Component\Mailer\Header\TagHeader;
use Symfony\Component\Mime\Email;
public function build()
{
$this->withSymfonyMessage(function (Email $message) {
$message->getHeaders()->add(new TagHeader('value'))
});
}
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mime\Email;
public function build()
{
$this->withSymfonyMessage(function (Email $message) {
$message->getHeaders()->add(new MetadataHeader('field', 'value'));
$message->getHeaders()->add(new MetadataHeader('another-field', 'another value'));
});
}
namespace App\Listeners;
use Illuminate\Mail\Events\MessageSent;
class HandleMessageSent
{
public function handle(MessageSent $message)
{
$messageId = $event->sent->getSymfonySentMessage()->getMessageId();
// ...
}
}
namespace App\Providers;
use App\Listeners\HandleMessageSent;
use Illuminate\Mail\Events\MessageSent;
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
MessageSent::class => [
HandleMessageSent::class,
],
];
}
use CraigPaul\Mail\PostmarkServerTokenHeader;
use Symfony\Component\Mime\Email;
public function build()
{
$this->withSymfonyMessage(function (Email $message) {
$message->getHeaders()->add(new PostmarkServerTokenHeader('POSTMARK_TOKEN'))
});
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.