Viewing file: test.php (1.78 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST");
ini_set('display_errors',1);
//$email = $_GET['email'];
//$message = $_GET['message'];
// your sendgrid api key
define( 'SENDGRID_API_KEY', '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' );
// from email address
define( 'FROM_EMAIL', 'support@srishticampus.com' );
// from name
define( 'FROM_NAME', 'Srishti Campus' );
// to email address
define( 'TO_EMAIL', 'raj.srishtis@gmail.com' );
// to name of user you are sending the email to
define( 'TO_NAME', 'Rajagopal Mahadevan' );
// require composer autoload so we can use sendgrid
require 'vendor/autoload.php';
// create new sendgrid mail
$email = new \SendGrid\Mail\Mail();
// specify the email/name of where the email is coming from
$email->setFrom( FROM_EMAIL, FROM_NAME );
// set the email subject line
$email->setSubject( "DailycarePlan Forgot Password" );
// specify the email/name we are sending the email to
$email->addTo( TO_EMAIL, TO_NAME );
// add our email body content
$email->addContent(
"text/html", 'Hi,this is a test message that sendgrid is working'
);
// create new sendgrid
$sendgrid = new \SendGrid( SENDGRID_API_KEY );
try {
// try and send the email
$response = $sendgrid->send( $email );
// print out response data
print $response->statusCode() . "\n";
print_r( $response->headers() );
print $response->body() . "\n";
} catch ( Exception $e ) {
// something went wrong so display the error message
echo 'Caught exception: '. $e->getMessage() ."\n";
}
?>
|