Thursday , November 7 2024

SENDING EMAIL WITH MANDRILL

Mandrill is a powerful SMTP provider. Developers tend to use a third party SMTP provider for better inbox deliveries.

For the below function you would have to put a file “Mandrill.php” in the same folder as the PHP file you would be using 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);
}

In the above code you would have to specify your own api key that you get from your Mandrill account.

Syntax:

<?php
$to = “abc@example.com”;
$subject = “This is a test email”;
$message = “Hello World!”;
send_email($to,$subject,$message);
?>

About admin

Check Also

Convert Text To Image

You can convert text to image by using this php code. You then download the image …

Leave a Reply