PHP code example of iyngaran / send-grid-transport
1. Go to this page and download the library: Download iyngaran/send-grid-transport 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/ */
namespace SendGridTransport\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use SendGridTransport\Mail\Transport\SendGridTransport;
class SendEmailController extends AbstractActionController
{
private $sendGridTransport;
private $config;
public function __construct(SendGridTransport $sendGridTransport, array $config)
{
$this->sendGridTransport = $sendGridTransport;
$this->config = $config;
}
public function indexAction()
{
$message = new \SendGridTransport\Mail\Message();
$body = '<strong>Hello :),</strong><BR/> The SendGridTransport is working now :)';
$message->setBody($body);
$message->setFrom(
new \Zend\Mail\Address(
$this->config['test-email']['from']['email'],
$this->config['test-email']['from']['name']
)
);
$message->addTo(
new \Zend\Mail\Address(
$this->config['test-email']['to']['email'],
$this->config['test-email']['to']['name']
)
);
$message->setSubject('Testing SendGridTransport - Iyngaran');
$message->setBodyText('Hello, the SendGridTransport is working now :)');
print('<pre>');
print_r($this->sendGridTransport->send($message));
print('<pre/>');
return [];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.