Getiing error during email send process I am using PepiPost mail service for sending an email. PepiPost mail service provides an SDK for send sending mail. They provided a sample code for sending mail. 

When I send the mail getting the following error message:


  Unable to send e-mail. Contact the site administrator if the problem
  persists.


But mail is sent to the corresponding user and user can receive the mail.

I have created a Custom mail system call by implementing 
MailSystemInterface. The code is available in the here. Although this is the code I placed in mail()  function.

class TestMailSystem implements MailSystemInterface {
  require_once __DIR__.'/includes/vendor/autoload.php';

  use PepipostAPIV10Lib\Controllers\Email;


  public function format(array $message) {
    // Join message array.
    $message['body'] = implode("\n\n", $message['body']);
    return $message;
  }

public function mail(array $message) {


$email = new Email();

$data = array(
      'api_key'   =&gt;  '************',
      'recipients'    =&gt;  $message['to'],
      'email_details' =&gt; array(
        'from'          =&gt;  $message['from'],
        'subject'       =&gt;  $message['subject'],
        'content'       =&gt;  $message['body'],
        'fromname'      =&gt;  $message['fromname'],
        'tags'          =&gt;  'test',
        'replytoid'     =&gt;  $replyto,
      ),
      'X-APIHEADER' =&gt; array('UserID1','UserID2'),
      'settings' =&gt; array(
        'footer'        =&gt;  true,
        'clicktrack'    =&gt;  true,
        'opentrack'     =&gt;  true,
      ),
    $response = $email-&gt;sendJson( $data );
}

}


When I send the mail getting the following error message:


  Unable to send e-mail. Contact the site administrator if the problem
  persists.


User receives the email. What would the reason for the error message be?
MailSystemInterface::mail has a particular return value:


  TRUE if the mail was successfully accepted for delivery, otherwise FALSE.


The caller uses that to determine whether or not the mail was sent successfully, so just return TRUE when the mail succeeds and the error will stop.