Skip to content

Instantly share code, notes, and snippets.

@agronom81
Created October 4, 2017 12:19
Show Gist options
  • Save agronom81/831c6cb54b65d1833bf323b4bdc0e1f4 to your computer and use it in GitHub Desktop.
Save agronom81/831c6cb54b65d1833bf323b4bdc0e1f4 to your computer and use it in GitHub Desktop.
function mailTo ( $emails, $subject, $message ) {
$mail = new PHPMailer;
$mail->isSMTP();
$mail->isHTML(true);
$mail->setFrom( SITE_EMAIL, SITE_NAME );
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = SMTP_LOGIN;
$mail->Password = SMTP_PASS;
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
if ( !is_array($emails) ) $emails = [ $emails ];
foreach ( $emails as $key ) $mail->addAddress( $key );
$mail->Subject = $subject;
$mail->Body = $message;
return ( $mail->send() ) ? true : false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment