I need help with email


I’d like to get email off my server but no matter what I try (Amazon SES, MailGun or any of the other popular solutions) all I get are “connection refused” errors in my logs. I’m using forum software, I made sure the ports are opened on the server, I’ve configured MailGun and CloudFlare the way MailGun instructed me too, I’ve got the credentials right in the forum software. I’ve even tried MailGun’s API. Something is wrong somewhere and I can’t figure it out. And no matter who I ask, it’s a problem on “the other guy’s” end. I really hope somebody can help me out here. Any assistance would be greatly appreciated…


Does any of the following need to be set ON THE SERVER if I have it set in CPanel to use a remote mail server?

A Record, CNAME Record, MX Record, DNSSEC



Keeping email off your origin server is a good idea.

Well, I have not used MailGun. I have experienced with Gmail (GSuite) and ZohoMail. Whatever mail services you want to use, as they suggest you need to update DNS records accordingly at Cloudflare Dashboard, Most likely it will be Mx Records, TXT or some time it also being some CNAME.

Can you please elaborate your query? Do you want to have the website via origin server where is cPanel, but custom domain Email from outside server, instead of traditional cPanel email?



Thank you for responding. When I go into CPanel and select the Zone Editor option - I see the ability to add settings for A Record, CNAME Record, MX Record, and DNSSEC. Do I need to set any of these if I’m using CloudFlare?


I am not sure cPanel based DNS zone manager will work or not.

I think, for email better will be you can directly update required records at Cloudflare.


  1. Login to Cloudflare
  2. Go to DNS manger
    You will see URL like this
  3. Choose record type (e.g. MX, TXT, CNAME)
    Add name, Add value, keep time ‘Automatic’

Wait for 5 minutes. Your email should work fine.

Note: For updating DNS records, you shouldn’t remove A record and CNAME else your site may go down. Feel feel to keep more than one type of similar records like two TXT, if needed.


Saving for later…


Hmm. Does anything look wrong with my configuration?


Looks fine!! Can you check again email working or not?


Thank you. For some reason I’m just not having any luck with this. It won’t work any way I try it. I really don’t understand. :expressionless:


Here’s what’s in my forum error log:

Zend_Mail_Protocol_Exception: Email to [email protected] failed: Connection refused - library/Zend/Mail/Protocol/Abstract.php:277
Generated By: Unknown Account, A moment ago
Stack Trace
#0 /home/site/folder/library/Zend/Mail/Protocol/Smtp.php(167): Zend_Mail_Protocol_Abstract->_connect(‘tcp://smtp.mail…’)
#1 /home/site/folder/library/Zend/Mail/Transport/Smtp.php(216): Zend_Mail_Protocol_Smtp->connect()
#2 /home/site/folder/library/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail()
#3 /home/site/folder/library/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#4 /home/site/folder/library/XenForo/Mail.php(175): Zend_Mail->send(Object(Zend_Mail_Transport_Smtp))
#5 /home/site/folder/library/XenForo/Mail.php(152): XenForo_Mail->sendMail(Object(Zend_Mail))
#6 /home/site/folder/library/XenForo/Model/UserConfirmation.php(253): XenForo_Mail->send(‘[email protected]….’, ‘Username’)
#7 /home/site/folder/library/XenForo/ControllerPublic/LostPassword.php(84): XenForo_Model_UserConfirmation->sendPasswordResetRequest(Array)
#8 /home/site/folder/library/XenForo/FrontController.php(351): XenForo_ControllerPublic_LostPassword->actionLost()
#9 /home/site/folder/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#10 /home/site/folder/index.php(13): XenForo_FrontController->run()
#11 {main}
Request State
array(3) {
[“url”] => string(44) “https://sitename.com/lost-password/lost
["_GET"] => array(0) {
["_POST"] => array(4) {
[“username_email”] => string(13) “Username”
[“adcopy_response”] => string(14) “security phrase“
[“adcopy_challenge”] => string(334) “[email protected]@XWarjdvnXlEENU8bgrS8bH9APTC4lJjoSvFvNcYLpb6lvF.-NuKtVt1YdUsiUgCtbbSKf1CFwMB82wCwLI5swtWn359N1X-ExWJn-oAABRc8s.6ysDMeJlUUccQpNtbAGCbVYdwPdLzMjhaCJmgwuVgY6VKsPE.mzWvUkcV-eoTk0Ui-.qx.AvyHUmEGyYOisjO2GFJZ2djshkkjjU0LxD8qjhNkKSPuHiYatryKA4wSOYIJMG71s-EMwI0NyPo2XCUW7xdXMWRnleGtPSCQzRA2iaaZJVhGRDjJkhFXIK0uoA”
["_xfToken"] => string(8) “********”


It should work. It is really not that much complicated thing. May be it takes some time.

Or, if possible you can try another services except Mailgun.

Even today, I have done setup of my another email account with an external email service provider, same way, it works fine. There is no any issue.


Okay. Thank you. If it looks right in that image I posted - then the problem must lie somewhere else. I’ll keep looking. Have a great day!


D you have shell access on this server? Can you type “telnet mxa.mailgun.org 25” from a prompt and see if it connects? That will verify your server can communicate outbound on port 25.

Looking at the log snippet you posted this section: "tcp://smtp.mail… " appears like the script is trying to communicate with something other than mailgun based on the host name vs. what mailgun requires. I don’t know enough about the system to comment further, but if you can connect to the mailgun host on port 25 it isn’t a server problem per se, but likely a software config issue.


Thank you. When I try that command, I get the following:

-bash: telnet: command not found

What do I need to do?


You may need to install telnet, here’s an article which desribed how for a few different linux installs: https://serverfault.com/questions/175041/bash-telnet-command-not-found-error


Thank you. I installed it and get the following:

Connected to mxa.mailgun.org.
Escape character is ‘^]’.
220 ak47 ESMTP ready

Good or bad?


Good, means your server isn’t blocked from connecting to the external server. So if it’s trying to send SMTP directly to mailgun that isn’t the issue. So it’s likely a config issue in the software/setup for whatever app you’re configuring with railgun (and unlikely to be Cloudflare specific in nature). Might try opening a support ticket with them to see if they have any insight (I’ve only briefly played with railgun for making a discord server send mail so not an expert by any means).


Thank you very much. I appreciate your help and insight here. :slight_smile:


Okay, stopping by again with an update. I’ve tried using SendGrid and even tried different forum software (vBulletin) - and I’m still having no luck.

What’s really got me here is - it appears my server has the right stuff to make the connection OUT. I just have a feeling that something else is missing server-side. What could that possibly be? Any ideas? I’m pretty confident I have my settings correct at CloudFlare, there’s not much that can go wrong at the forum-side (XenForo, vBulletin) and I’m pretty sure both SendGrid and MailGun are working as they should be.

If I were to go to my server administrator and ask for them to try and figure out what’s wrong - where would I begin? What would I ask? They’re saying everything looks fine but I’m just not feeling good about that…


@Castellano has email ever worked on your server ? some web hosts block smtp until some for of id verification is made i.e Vultr does this for new accounts