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 in PHP by Kichu
• 19,040 points
1,354 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 in PHP by narikkadan
• 37,660 points
569 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,800 points
338 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
9,795 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,800 points
511 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,800 points
1,214 views
0 votes
0 answers
0 votes
0 answers

phpmailer error "Could not instantiate mail function"

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

Jun 13 in PHP by narikkadan
• 37,660 points
695 views
0 votes
1 answer

SMTP connect() failed PHPmailer - PHP

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

answered Feb 16 in Others by Aditya
• 7,660 points
1,878 views
0 votes
0 answers

"SMTP Error: Could not authenticate" in PHPMailer

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

May 7 in PHP by narikkadan
• 37,660 points
2,265 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