phpのPearのMAILライブラリを使ってsendgridでのメール送信

引数でfrom to指定して空メール送信

<?php

try {

	$char = "UTF-8"; //PHPファイルがUTF-8でかかれている場合
	$from_addres = $argv[1];
	$to_addres = $argv[2];

	$message = "";
	$make_subject = "";

	$message=mb_convert_encoding($message,"JIS",$char);
	$headers['Subject']	="=?iso-2022-jp?B?".base64_encode(mb_convert_encoding($make_subject,"JIS",$char))."?=";
	$headers['From']	= $from_addres ;
	$headers['To']	= $to_addres ;

	$params['host']	= "smtp.sendgrid.net";
	$params['port']	= 25;
	$params['auth']	= "LOGIN";
	$params['username']	= "apikey";
	$params['password']	= "APIキー";
	$params["persist"]	= FALSE;

	include_once 'Mail.php';
	$mailer =& Mail::factory( "smtp", $params);
	$mailer->send($to_addres, $headers, $message);

} catch (Exception $e) {
    echo '捕捉した例外: ',  $e->getMessage(), "<br>\n";
}

?>