You need to use PEAR library and the PHPMailer class to send thru an external SMTP server with authentication.
Code: Select all
require_once('/library/PHPMailer/class.phpmailer.php');
$mail = new \PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = 'login';
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'example@gmail.com';
$mail->Password = 'somepassword';
$mail->SetFrom('example@gmail.com', 'Example');
$mail->Subject = 'The subject';
$mail->Body = 'The content';
$mail->AddAddress('receiver@gmail.com');
$mail->Send();