For Developers By Developers

You can integrate Mailazy in minutes with your platform. Build and monitor your email solution on a trusted foundation with technical and strategic support when you need it the most.

Trusted by 145+ customers and delivering over 18 Million emails/month.

Configure Email API with PHP

Configure Email API with PHP

The Mailazy platform helps you to send transactional emails seamlessly and track email deliverability and enables your applications to send messages via a simple HTTP REST interface. When you sign up for a free Mailazy account, you'll be able to send 350 emails per day forever. For more account options, see our pricing page.

Mailazy has recently released a PHP library that will allow you to send email from Mailazy email API. This library gives you full access to all of the features offered by our PHP Email API. APIs, in general, have better delivery speeds and can be executed in less than a second.

This doesn’t mean that sending email using SMTP is going to be slow, but API has less back and forth and reduces the potential steps for failure when sending an email.

Benefits

  • The Mailazy PHP library has cURL or FSOCKOPEN dependencies.

  • It is easy to build, customize, and send emails, including email messages with to, from, cc, bcc, reply_to, attachments, and custom headers.

  • The library also has a ton of pre-written code examples to demonstrate more advanced topics like sending bulk mail, merge data, and other features.

Prerequisites

You need to complete these given prerequisites, you can skip the step if you have already completed.

  1. Sign up for a Mailazy account.

  2. Complete Domain Authentication.

  3. Generate the Mailazy Access Key

  4. PHP installed and configured

Integration with PHP

  • Create a PHP demo project via Initialize composer.

Composer init  
  • Create a php file to setup a demo mailazy sending project with name index.php

  • Install the mailazy package via composer, simple type the following in your terminal:

composer require mailazy/php-sdk
  • Start Sending mail using the code provided below in the index.php file.


define('MAILAZY_APIKEY','xxxxxxxxxxxxxxxxxxxxxxxx');// mailazy apikey replace at "MAILAZY_APIKEY"
define('MAILAZY_APISECRET','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');// mailazy apikey replace at "MAILAZY_APISECRET"

require 'vendor/autoload.php';

$mailazyClient = new mailazyAPI();
$mailazyClient->setApikey(MAILAZY_APIKEY);
$mailazyClient->setApisecret(MAILAZY_APISECRET);
$mailazyClient->isHTML(true);
$mailazyClient->addAddress($email,$userName);
//Set CC address
$mailazyClient->addCC($email,$userName);
//Set BCC address
$mailazyClient->addBCC($email,$userName);
$mailazyClient->setSubject($subject);
$mailazyClient->setBody($message);
$mailazyClient->setFrom($senderEmail,$sendername);
$mailazyClient->addReplyTo($replyEmail,$replyname);
$mailazyClient->addAttachment($filePath);
$mailazyClient->send();  
  • Update Mailazy credentials with your Mailazy Account in above code.

  • Now save index.php file and hit project URL

  • Now you will get email at your provided receipt email address.

Troubleshooting

  • To enable error reporting in php add the following line of code in index.php file at top.

ini_set('display_errors',  1);
ini_set('display_startup_errors',  1);
error_reporting(E_ALL);

Send transactional emails with Mailazy

Mailazy email delivery platform is powered by AI and uses the global infrastructure so that you can scale effortlessly. Mailazy is the trusted transactional email provider for hundreds of businesses and we are growing every day. We are known for being the most reliable and trusted senders on the internet.

Ready to get started?

Get started — it's free