Sending Mail with sendgrid
Add CRS/SendGridBundle to your composer.json file.
{
"require": {
"crs/sendgrid-symfony": "~1.0"
}
}
Add path in appKernel.php in bundle variable.
$bundles = [
....
....
....
new CRS\SendgridBundle\SendGridBundle(),
];
composer require crs/sendgrid-symfony
Add configuration to your config.yml file
#SendGrid API Access
send_grid:
key: "%send_grid_key%"
status: "%send_grid_status%"
How to send the mail:
$sendmail = new crs_mail();
$sendmail->setFrom(<%SENDER-EMAIL%>);
$sendmail->setTo(<%RECIPIENTS-EMAIL%>);
$sendmail->setSubject(<%EMAIL-SUBJECT%>);
$sendmail->setBody(<%EMAIL-BODY%>);
$sendmail->setTemplate(<%TEMPLATE-ID%>);
$sendmail->setSubsitute(array(
'<%SUBSITUTE-1%>' => <%SUBSITUTE-1-VALUE%>,
'<%SUBSITUTE-2%>' => <%SUBSITUTE-2-VALUE%>,
.....
'<%SUBSITUTE-n%>' => <%SUBSITUTE-n-VALUE%>,
));
$sendmail->addAttachment(array(
<%FILE-PATH-1%>,
<%FILE-PATH-2%>,
.......
<%FILE-PATH-n%>,
));
$sendmail->sendMail(<%CONTENT-TYPE%>);
How can I help you explore Laravel packages today?