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
• 15,450 points
21 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
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,680 points
249 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
4,336 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,680 points
367 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,680 points
951 views
0 votes
1 answer

Error:PDOException could not find driver

Hello @kartik, You need to have a module ...READ MORE

answered Sep 14, 2020 in PHP by Niroj
• 82,680 points
6,403 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,280 points
196 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
• 7,860 points
27 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
505 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
8,983 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP