I was able to send mails with PHPMailer.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$sender = getenv('CLOUDRON_MAIL_FROM');
$senderName = 'LAMP Test Email';
$recipient = 'test@cloudron.io';
$usernameSmtp = getenv('CLOUDRON_MAIL_SMTP_USERNAME');
$passwordSmtp = getenv('CLOUDRON_MAIL_SMTP_PASSWORD');
$host = getenv('CLOUDRON_MAIL_SMTP_SERVER');
$port = (int) getenv('CLOUDRON_MAIL_SMTP_PORT');
$subject = 'Cloudron test (SMTP interface accessed using PHP)';
$bodyText = "Email Test\r\nThis email was sent through the
Cloudron SMTP interface using the PHPMailer class.";
$bodyHtml = '<h1>Email Test</h1>';
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->setFrom($sender, $senderName);
$mail->Username = $usernameSmtp;
$mail->Password = $passwordSmtp;
$mail->Host = $host;
$mail->Port = $port;
$mail->SMTPAuth = true;
$mail->addAddress($recipient);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $bodyHtml;
$mail->AltBody = $bodyText;
$mail->Send();
echo "Email sent!" , PHP_EOL;
} catch (phpmailerException $e) {
echo "An error occurred. {$e->errorMessage()}", PHP_EOL; //Catch errors from PHPMailer.
} catch (Exception $e) {
echo "Email not sent. {$mail->ErrorInfo}", PHP_EOL;
}
?>
(Adapted from https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.html )