Mandrill is a powerful SMTP provider. Developers tend to use a third-party SMTP provider for better inbox delivery.
In the following function, you need to put "Mandrill.php" in the same folder as a PHP file, so that you can use TA to send emails.
- 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);
- }
Copy code
"$apikey = 'XXXXXXXXXX'; //specify your api key here" Here you need to specify your API key (obtained from Mandrill account).
Syntax:
- $to = "abc@example.com";
- $subject = "This is a test email";
- $message = "Hello World!";
- send_email($ to,$subject,$message);
- ?>
Copy code
|