isSMTP(); // Set mailer to use SMTP $mail->Mailer = "smtp"; // Set required parameters for making an SMTP connection $mail->SMTPDebug = 1; // Enable verbose debug output $mail->SMTPAuth = TRUE; // Enable SMTP authentication $mail->SMTPSecure = "tls"; // Enable TLS encryption, 'ssl' (a predecessor to TSL) is also accepted $mail->Port = 587; // TCP port to connect to (587 is a standard port for SMTP) $mail->Host = "smtp.gmail.com"; // Specify main and backup SMTP servers $mail->Username = "youremail@gmail.com"; // SMTP username $mail->Password = "yourpassword"; // SMTP password // Specify recipients $mail->setFrom('from-email@gmail.com', 'name-is-optional'); $mail->addAddress('to-email@virginia.edu', 'name-is-optional'); $mail->addAddress('another-to-email@virginia.edu'); $mail->addReplyTo('reply-to-email@virginia.edu', 'name-is-optional'); $mail->addCC('cc-email@example.com'); $mail->addBCC('bcc-email@example.com'); // Specify email content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Subject line goes here'; $mail->Body = 'Body text goes here'; // Send email $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } ?>