Finally, I make it work. for your link, I list the steps (for myself as well)
1) we need to download the sendgrid-php package from https://github.com/sendgrid/sendgrid-php/downloads
2) Unzip the folder and place it in the project folder, for example, "app / mail /".
3) create one .php file for mail to send mail in this folder, for example, "app / mail / mail.php".
4) in this file
<?php session_start(); define("ROOT_DIR", __dir__ . DIRECTORY_SEPARATOR); function sendGrid_loader($string) { if (preg_match("/SendGrid/", $string)) { $file = str_replace('\\', '/', "$string.php"); require_once ROOT_DIR . $file; } } spl_autoload_register("sendGrid_loader"); $sendgrid = new SendGrid('sendgrid_username', 'sendgrid_password'); $mail = new SendGrid\Mail(); $mail->addTo(' foo@bar.com ')-> setFrom(' me@bar.com ')-> setSubject('Subject goes here')-> setText('Hello World!')-> setHtml('<strong>Hello World!</strong>'); ?>
5) I need to send mail when I redirect to the mailsend page. so I write the code in the controller file in Actionmailsend (),
" header("Location:".AT::getUrl()."/mail/mail.php"); ".
just a redirect. this is. mail is sent successfully.
source share