SMTP Error: PHPMailer

And this is the code that i’ve been using on my index.php

Hello everyone. I have an issue with implementing those PHPMailer on my link

And this is the error message that I get when opening the link :

2020-05-22 20:54:08 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. -> this shows the github page troubleshooting
Mailer Error: SMTP connect() failed. -> this shows the github page troubleshooting

I already follow all the step that has been given, changing the field email and host yet still getting those error. Can anyone help me with this? Thank you very much :slightly_smiling_face:

Hi. From what I see in the screenshot, you currently have the host set as localhost, when it should be set as smtp.gmail.com. This is most likely the reason you’re getting an error and not being able to connect to SMTP. :slight_smile:

Hello Mr. Austin. In the beginning, I tried to change the host to smpt.gmail.com too, but yet it still showing another error like in the picture. Is that an issue from my Gmail account? But I already change all the preferences in Gmail that needed, so the code supposed to be work right? Can you help me with this Mr. Austin? Thank you very much :slightly_smiling_face:

Are you using two-factor authentication on your Google account?

A few more things to try:

  • Ensure less secure apps is off (Click here)
  • Complete the reCaptcha to allow account access (Click here)

Oh, shoot. Hey there Mr. Austin. So I just changed the account of my Gmail in the code, settings the preferences on the Gmail Setting and it just shows this on my link site

So when showing the log “Message Sent” like the picture above, my problem is clear right? Even there’s another log process before it? Cause I got the email message that has been sent to my other Gmail account :slightly_smiling_face:

Sorry I’m not very fluent spoken English.

If I’m understanding correctly, this is working now? Are you wanting the logs to be displayed or are you wanting those hidden?

Yep that code already work correctly because my other Gmail account has received the test mail. And yes how to hide the logs when it already showing “Message Sent”? Did I just need to remove the echo "Mailer error: "…?

Oh Mr. Austin and one more thing that I want to ask. I have a form that I used like this one:

*short description: so I use a button sent an email for sending a message to the Gmail account. But what I can’t get is how can I send messages to selected Gmail accounts based on transaction IDs in the database?
the database for this form has contained the Gmail account for the user. Thanks

This topic was automatically closed after 6 days. New replies are no longer allowed.