0

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'   =>  '************',
      'recipients'    =>  $message['to'],
      'email_details' => array(
        'from'          =>  $message['from'],
        'subject'       =>  $message['subject'],
        'content'       =>  $message['body'],
        'fromname'      =>  $message['fromname'],
        'tags'          =>  'test',
        'replytoid'     =>  $replyto,
      ),
      'X-APIHEADER' => array('UserID1','UserID2'),
      'settings' => array(
        'footer'        =>  true,
        'clicktrack'    =>  true,
        'opentrack'     =>  true,
      ),
    $response = $email->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?

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.