PHPMailer

Aquí puedes ver un ejemplo de código utilizado para enviar Emails Transaccionales a través de PHP Mailer:

<?php
// PHP Mailer previously installed // See https://github.com/DopplerRelay/docker-php/blob/master/Dockerfile include_once "/usr/lib/vendor/phpmailer/phpmailer/PHPMailerAutoload.php"; // Get username and password from environment variables $username = getenv('DOPPLERRELAY_USERNAME'); $password = getenv('DOPPLERRELAY_PASSWORD'); // Relay SMTP service configuration $host = 'smtp.dopplerrelay.com'; $port = 587; // Custom data $fromEmail = '[email protected]'; $fromName = 'Your Name'; $to1Email = '[email protected]'; $to1Name = 'Recipient1 Name'; $to2Email = '[email protected]'; $to2Name = 'Recipient2 Name'; $subject = 'Hello from Doppler Relay, PHP Mailer!'; $text = "Doppler Relay speaks plaintext"; $html = "Doppler Relay speaks HTML"; // Send message using PHP Mailer $mail = new PHPMailer; $mail->IsSMTP(); $mail->Host = $host; $mail->Port = $port; $mail->SMTPAuth = true; $mail->AuthType ='LOGIN'; $mail->Username = $username; $mail->Password = $password; $mail->From = $fromEmail; $mail->FromName = $fromName; $mail->AddAddress($to1Email, $to1Name); $mail->AddAddress($to2Email, $to2Name); $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $html; $mail->AltBody = $text; if(!$mail->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } echo 'Message has been sent';