PHP Tutorial: How To Send Email From Localhost Using PHPMailer
Why Stack Overflow recommends it
Stack Overflow users cite it as the tutorial they followed when setting up PHPMailer over SMTP, usually in questions about connection or host errors that came up while following it.
Recommended by 0 people across 0 different months, 2019 to 2021.
What it is
A 23-minute PHP tutorial by Senaid Bacinovic showing how to send email from a localhost setup with the PHPMailer library. It builds a contact form, validates inputs with jQuery, and sends mail over SMTP, covering plain text, HTML and attachment emails.
What people said
Cites Adharsh Ravi · 2019-04 · Stack Overflow · on “I keep getting host error while sending a mail through php”
I have been trying to create a php mailing system for my web application using this [this video] reference. But I dont know if there is an error in my code or mail. I'm using windows 7, php 7, latest version of phpmailer and xampp v3.3.2 <?php use PHPMailer\PHPMailer\PHPMailer; require_once "PHPMailer/PHPMailer.php"; require_once "PHPMailer/SMTP.php"; require_once "PHPMailer/Exception.php"; $mail = new PHPMailer(); //SMTP Settings $mail->isSMTP(); $mail->SMTPDebug = 2; $mail->Host = "tls://smtp.gmail.com:587"; $mail->SMTPAuth = true; $mail->Username = "primeglobalhr@gmail.com"; $mail->Password = 'Password'; $mail->Port = 587; //587 $mail->SMTPSecure = "tls"; //tls //Email Settings $mail->isHTML(
Cites Meon · 2020-04 · Stack Overflow · on “PHPmailer fails,error: SMTP connect() failed”
I know this question was asked many times but I couldn't find something to solve my problem. I've read this posts: [LINK] [LINK] SMTP connect() failed phpmailer [LINK] and this is the tutorial I used: [this video] **the error I get is:**SMTP connect() failed. my code: <?php use PHPMailer\PHPMailer\PHPMailer; $name= $_POST['name']; $email= $_POST['email']; $message= $_POST['message']; $subject1 = "thank you for contacting CouplesLove Support! -No replay-"; $body1 = "hello $name! thank you for contacting us! we will replay to this email:$email <br> your message: $message <br><br> this is an automated message, please do not replay to this email"; $subject2 ="new contact submition from $name"; $body2
Cites John Beasley · 2021-01 · Stack Overflow · on “PHPMailer 6.2 stream_socket_client”
I switched over to using PHPMailer 6.2 (which is the master version, and most recent version). I am using Apache 2.4 on a Windows Server 2019. The version of PHP I am using is 7.4.12. Following this tutorial: [this video] I am not having much luck using the below code: <?php use PHPMailer\PHPMailer\PHPMailer; require 'PHPMailerAutoload.php'; require 'phpmailer/class.phpmailer.php'; require 'phpmailer/class.smtp.php'; $mail = new PHPMailer(); $mail->SMTPDebug = 4; $mail->isSMTP(); $mail->Host = 'xx.x.x.xxx'; $mail->SMTPAuth = false; // <- just changed to false $mail->Username = 'mycompany@email.com'; $mail->Password = 'mypassword'; $mail->Port = 25; $mail->SMTPSecure = 'tls'; // update $mail->SMTP