Yandex SMTP Email Sending Issues

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:

getsebool httpd_can_sendmail
getsebool httpd_can_network_connect

=====================

Here is the script

$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

Try ordering the settings like in this way:

$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "ssl://smtp.yandex.com:465";
$mail->SMTPAuth = true;
$mail->Username = "your Yandex email";
$mail->Password = "********"; // overwrite those asterisks with your Yandex password

However, true is a boolean value, not a string.

Hello Thank you for your reply but still no luck, same error message,

SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

Try to use the same code, but only with your Yandex username as username (the first part without @yandex.com part).

I have tried that, no it is still the same error,
2019-06-18 11:25:44 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed.

Do let me know is there any further steps needs to be taken, inorder to get it working.

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.

Maybe there is a Firewall on iFastNet’s end that blocks the access to smtp.yandex.com. I’m glad you got this working on XAMPP and WampServer.

Okay I will check and will give an update soon.

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.

Thank you infinity admin.

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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.