PHP & PHPMailer
PHPMailer is the most common way to send SMTP email from plain PHP. Point it at Signally, or call the REST API with curl.
PHPMailer over SMTP
| Host | smtp.signally.cloud |
|---|---|
| Port | 465 with SSL/TLS (recommended), or 587 with STARTTLS |
| Username | Your SMTP username, e.g. smtp-12-ab3xk9 |
| Password | The SMTP password shown once when you created the login |
Create an SMTP login under API & SMTP in your dashboard. It is separate from your API keys. The From address must be on a domain you have verified.
Install
composer require phpmailer/phpmailersend.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.signally.cloud';
$mail->SMTPAuth = true;
$mail->Username = getenv('SIGNALLY_SMTP_USER');
$mail->Password = getenv('SIGNALLY_SMTP_PASS');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // SSL/TLS on 465
$mail->Port = 465; // or ENCRYPTION_STARTTLS with port 587
$mail->CharSet = 'UTF-8';
$mail->setFrom('[email protected]', 'Your Shop');
$mail->addAddress('[email protected]', 'Wanjiru');
$mail->addReplyTo('[email protected]');
$mail->isHTML(true);
$mail->Subject = 'Your order has shipped';
$mail->Body = '<p>It is on its way!</p>';
$mail->AltBody = 'It is on its way!';
$mail->addAttachment('/path/to/invoice.pdf');
$mail->send();
} catch (Exception $e) {
error_log('Email failed: ' . $mail->ErrorInfo);
}While setting up, $mail->SMTPDebug = 2; prints the SMTP conversation. Remove it in production.
Or use the REST API
No library needed; see the PHP example in the quickstart. Attachments go in an attachments array as base64:
PHP
'attachments' => [[
'filename' => 'invoice.pdf',
'content' => base64_encode(file_get_contents('/path/to/invoice.pdf')),
'content_type' => 'application/pdf',
]],Keep keys and passwords in environment variables or your secrets manager, never in your code or Git repository. If one leaks, revoke it under API & SMTP and create a new one.
Stuck? Email [email protected] with your account name and the message ID or error code.