Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $mail = new PHPMailer(false); // Passing `true` enables exceptions
- //Server settings
- //$mail->SMTPDebug = 1;//Enable verbose debug output
- $mail->isSMTP();//Set mailer to use SMTP
- $mail->Host = 'smtp host';//Specify main and backup SMTP servers
- $mail->SMTPAuth = true;//Enable SMTP authentication
- $mail->Username = 'user';//SMTP username
- $mail->Password = 'password';//SMTP password
- $mail->SMTPSecure = 'tls';//Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587;//TCP port to connect to
- //Recipients
- $mail->setFrom('example@example.com','myapp');
- $mail->addAddress('hi@examle.com');//Add a recipient
- //$mail->addAddress('ellen@example.com');//Name is optional
- $mail->addReplyTo('support@example.com','Contact');
- //Content
- $mail->isHTML(true);//Set email format to HTML
- $mail->Subject = 'test';
- $mail->Body = 'this is a test';
- $mail->send();
- $mail->isSMTP();//Set mailer to use SMTP
- $mail->Host = 'smtp host';//Specify main and backup SMTP servers
- $mail->SMTPAuth = true;//Enable SMTP authentication
- //Assuming SMTP_USERNAME is your environment variable which holds username
- $mail->Username = getenv('SMTP_USERNAME');
- //Assuming SMTP_PASSWORD is your environment variable which holds password
- $mail->Password = getenv('SMTP_PASSWORD');
- $mail->SMTPSecure = 'tls';//Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587;//TCP port to connect to
Add Comment
Please, Sign In to add comment