I have been trying to use smtp email from Yandex, it is not working on Infinityfree server. It is working in another server and also it is working on my desktop computer.
Not just Yandex I have tried Gmail as well same error message.
I have done a lot of debugging but still cannot fix it. Can you let me know whether it is because some thing in blocked on the server. I get the message “Failed to connect to server: (0) SMTP connect() failed. https:[slash][slash]github[dot]com[slash]PHPMailer[slash]PHPMailer[slash]wiki[slash]Troubleshooting”
Following is the point from PHPmailer,
SELinux blocking
If you see an error like SMTP → ERROR: Failed to connect to server: Permission denied (13), you may be running into SELinux preventing PHP or the web server from sending email. This is particularly likely on RedHat / Fedora / Centos. Using the getsebool command we can check if the httpd daemon is allowed to make a connection over the network and send an email:
$mail = new PHPMailer();
$mail->IsSMTP();
//$mail->Host = “smtp.yandex.com”;
$mail->Host = gethostbyname(‘smtp.yandex.com’); //[The was to check if IPv6 was blocked]
$mail->Username = “######@yandex#####”;
$mail->Password = “************”;
$mail->SMTPAuth = “true”;
$mail->SMTPSecure = “ssl”;
$mail->Port = 465;
$mail->SMTPDebug = 2;
=====================
Can you help me out, website link https:[slash][slash]wisheroo[dot]cf[slash]login-register.php
Kindly let me know your views. Also, i have been discussing with the Yandex support and they have checked to contact hosting provider. I thought about it uploaded in a hostgator server and it worked. And as i have said it worked on my computer as well.
IPv6 is not blocked. Try to uncomment $mail->Host = "smtp.yandex.com" and comment $mail->Host = gethostbyname('smtp.yandex.com'), then ensure you’re using the right credentials of your Yandex.Mail account.
Thank you for your response
I tried as per your instruction but no luck. It is still giving the same error.
SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
In the Yandex site you don’t need to do nothing, just make sure you use Yandex username (the part before @yandex.com) and password (it will be the app-specific password if you enabled Two-Factor Authentication on your Yandex account) on PHPMailer.
I have used the user name without the trailing domain “@yandex.com” and I donot have any two step verification. Also, as i said earlier it is working on my desktop xamp and wamp server.
I’ve been checking this issue, and I see a few things in your code which draw my attention:
The $mail->Host field should only be the host. It does not include port numbers or protocols. It seems that PHPmailer accepts this just fine, but I’m not sure how it will interpret them.
The username and password you’re using look odd. Normally, the username is the full email address of the account, and the password is whatever you have configured with the email provider.
I have facing the issue for a long time. I have checked all possible option and checked with Yandex but no luck. I have also contacted Cloudflare for the firewall issue, they said they do not block the port. Now, I am wondering what is wrong, As I have said earlier. The script works fine in wamp, xamp and other servers but no luck in infinityfree host.
FYI, I moved your post back to your own topic. I’m unable to say for certain the issue is actually the same, so let’s keep the topics separate for now.
I checked this issue on your site before with more verbose debugging, and it looks like there might be some option with SSL. I’m going to look into this.
I do not know whether you have some thing or made some changes to your server, but I am getting 502 Bad gateway while logging into the website to check. Thus cannot check the site.