PHPMailer SMTP Error Could not connect to SMTP host

0 votes

I am having trouble sending mail through PHP but it works when I send mail through Thunderbird.

This is my thunderbird settings:

Server name: mail.exampleserver.com

Port: 587

Username: user@exampleserver.com

Secure Authentication: No

Connection Security: STARTTLS

This is my PHP code:

 $mail = new PHPMailer();

 $mail->IsSMTP(); // send via SMTP

 $mail->Host = SMTP_HOST; // SMTP servers

 $mail->Port = SMTP_PORT; // SMTP servers

 $mail->SMTPAuth = true; // turn on SMTP authentication

 $mail->Username = SMTP_USER; // SMTP username

 $mail->Password = SMTP_PASSWORD; // SMTP password

 $mail->From = MAIL_SYSTEM;

 $mail->FromName = MAIL_SYSTEM_NAME;

 $mail->AddAddress($aSecuredGetRequest['email']);

 $mail->IsHTML(true); // send as HTML

What am I doing wrong here? How can I solve this?

May 8, 2022 in PHP by Kichu
• 19,040 points
3,124 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
0 answers

PHPMailer SMTP ERROR: Failed to connect to server

This Code: <?php include("class.phpmailer.php"); include("class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // ...READ MORE

Jun 27, 2022 in PHP by narikkadan
• 63,600 points
1,944 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,840 points
1,087 views
0 votes
2 answers

Error:“Cannot Connect to Server - A network-related or instance-specific error”?

Hello, The "sql server error 40" is appears mostly ...READ MORE

answered Aug 18, 2020 in PHP by Fantazma
• 140 points
29,315 views
0 votes
1 answer

Error:Cannot connect to database server Communications link failure

Hello @kartik, Setting the bind-address to the server's network IP ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,840 points
1,226 views
0 votes
1 answer

Error: Can't connect to MySQL server on 'my.application.com' (10061)

Hello @kartik, To directly login to a remote ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,840 points
1,962 views
0 votes
0 answers

Mailer Error: SMTP connect() failed in php mailer( https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)

Here is code for sending email from ...READ MORE

Jun 2, 2022 in PHP by Kichu
• 19,040 points
13,085 views
0 votes
0 answers

phpmailer error "Could not instantiate mail function"

I'm getting the error "Mailer Error: Could ...READ MORE

Jun 13, 2022 in PHP by narikkadan
• 63,600 points
2,421 views
0 votes
1 answer

SMTP connect() failed PHPmailer - PHP

 You need to add the Host parameter $mail->Host ...READ MORE

answered Feb 16, 2022 in Others by Aditya
• 7,680 points
4,521 views
0 votes
0 answers

"SMTP Error: Could not authenticate" in PHPMailer

I want to send emails in Gmail ...READ MORE

May 7, 2022 in PHP by narikkadan
• 63,600 points
4,522 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP