Mandrill 是一款强大的 SMTP 提供器。开发者倾向于使用一个第三方 SMTP provider 来获取更好的收件交付。
下面的函数中,你需要把 “Mandrill.php” 放在同一个文件夹,作为 PHP 文件,这样就可以使用TA来发送邮件。 - function send_email($to_email,$subject,$message1)
- {
- require_once 'Mandrill.php';
- $apikey = 'XXXXXXXXXX'; //specify your api key here
- $mandrill = new Mandrill($apikey);
-
- $message = new stdClass();
- $message->html = $message1;
- $message->text = $message1;
- $message->subject = $subject;
- $message->from_email = "blog@koonk.com";//Sender Email
- $message->from_name = "KOONK";//Sender Name
- $message->to = array(array("email" => $to_email));
- $message->track_opens = true;
-
- $response = $mandrill->messages->send($message);
- }
“$apikey = 'XXXXXXXXXX'; //specify your api key here”这里需要你指定你的 API 密钥(从 Mandrill 账户中获得)。
语法: - $to = "abc@example.com";
- $subject = "This is a test email";
- $message = "Hello World!";
- send_email($to,$subject,$message);
- ?>
|