Use PHPMailer to send email through the Lettermint SMTP relay from PHP.
This guide covers SMTP integration. For full configuration options and available headers, see the SMTP Introduction.
Installation
Install PHPMailer via Composer:
Code
composer require phpmailer/phpmailer
Basic configuration
Use environment variables for credentials:
Code
<?php// Load from environment or config$smtpHost = 'smtp.lettermint.co';$smtpUsername = 'lettermint';$smtpPassword = getenv('LETTERMINT_PROJECT_TOKEN'); // Your Project API token
<?phpuse PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;require 'vendor/autoload.php';$mail = new PHPMailer(true);try { // Server settings $mail->isSMTP(); $mail->Host = 'smtp.lettermint.co'; $mail->SMTPAuth = true; $mail->Username = 'lettermint'; $mail->Password = getenv('LETTERMINT_PROJECT_TOKEN'); $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; // Recipients $mail->setFrom('sender@yourdomain.com', 'Your Name'); $mail->addAddress('recipient@example.com', 'Recipient Name'); // Content $mail->isHTML(true); $mail->Subject = 'Test Email'; $mail->Body = '<h1>Hello!</h1><p>This is a test email.</p>'; $mail->AltBody = 'Hello! This is a test email.'; $mail->send(); echo 'Message sent successfully';} catch (Exception $e) { echo "Message could not be sent. Error: {$mail->ErrorInfo}";}