I have a strong shared hosting plan from a company that provides unlimited email accounts but sadly I had some issues deploying a Laravel app on that plan because of the restrictions it has. now I want to use a VPS for my Laravel app but still want to use the cpanel email functionality on that plan to send and receive emails on the same domain that will host the Laravel app on the VPS but I really have no idea if it is possible and if it is then how should it set the DNS records to achieve that.
Short answer - yes, it is possible. And you can use Cloudflare too
I can admit I manage few domains just like that. Even, it is recommended to separate them just in case.
Separate server per need with different services, just as a websites are being hosted on a dedicated server, each domain/website is using Cloudflare Origin CA certificate, SSL setup on Full (Strict) SSL, while the e-mail is on shared cPanel (having it’s AutoSSL certificate for a mail hostname) or some other dedicated server (with Let’s Encrypt SSL certificate) or some third-party e-mail service like GSuite, Microsoft Office 365, etc.
All working fine and smoothly as far for now
- Create a Cloudflare account and add your domain
- Change your current domain name nameservers at your domain registrar to the Cloudflare one’s which you will be given in the process of adding your domain to your Cloudflare account
- Add the DNS records per need, for example
A type wwwand
yourdomain.comDNS records both pointed to your VPS IP address where your domain (website) content (Laravel?) is hosted (located) and make sure both are proxied
- Next one, create an
mail.yourdomain.comDNS record and point it to your “unlimited email accounts” cPanel hosting IP address where you use e-mail and make sure it is (DNS-only)
- Nevertheless, add an
MX typerecord pointed to that
- From cPanel you can check for SPF and DKIM records, and it is recommended to add them too (as a TXT type of DNS records) to your DNS tab at Cloudflare dashboard
- Furthermore, you would have to setup the HTTPS (both at your VPS as a web server and Cloudflare SSL/TLS tab) and have an SSL certificate for your root (naked) domain and www (even if you have more sub-domains just in case). In case you do not have an SSL certificate, you can use Cloudflare Origin CA certificate (see below for more info)
- Just in case, check and allow Cloudflare to connect to your origin host / server (whitelist Cloudflare IP addresses/ranges) in your Firewall / iptables, etc.
- Make sure your web server / app is working over one of the supported and compatible Cloudflare ports - when the proxied mode is active
Helpful articles following as above steps:
More useful tutorials can be found here:
Helpful tutorials following above steps:
In case you do not have an SSL certificate, you can use Cloudflare SSL, if so, kindly make sure you follow the instructions as follows on the below article to setup an SSL certificate using Cloudflare CA Origin Certificate:
Last but not least, kindly have a look here for more information regarding correct SSL settings:
Check if Cloudflare is allowed to connect to your origin host to as follows in the below article:
Ports list compatible and supported when using cloud (proxy mode) on Cloudflare can be found here:
Due to the e-mail, I would suggest looking at the below articles too:
To manage the DNS records at the DNS tab, usefull for help:
thanks for the thorough response. i followed as per your instruction and everything is ok except that i receive emails with a delay of 5-10 min but sent emails get delivered almost instantly. maybe i missed something? i attached the DNS records but i retracted the IPs and domains. would appreciate if you take a look at it and give me feedback if im missing something.
All looks good to me as far for now
E-mail (A mail and MX) is setup correctly.
I am not 100% sure why is the delay.
May I ask is the delay while using Webmail interface (like Roundcube), or in your app like MS Outlook, Mozilla Thunderbird, etc.?
Or if it is shared hosting cPanel for e-mail, maybe due to more than only your e-mail (more users and server load, etc.)?
Or, maybe you would have to check by looking into the Track Delivery and check the mail headers like sent/received and inspect if it could be something in between?
Or, if using some digital signature when sending e-mails, or like GPG for signing them?
Or, if there is some anti-virus/spam checking and setup like amavisd, clamav, etc., on that cPanel hosting causing this delay for sending/receiving?
Or, may I ask you to re-check your IMAP/POP3 and SMTP server in your e-mail client app (MS Outlook, etc.) if you are using
Hopefully, using e-mail over an secured connection (SSL) as well?
Furthermore, in case of troubleshooting, may I suggest few online tools (if not already used) to check and test your e-mails:
- STARTTLS delivery test · SSL-Tools
- About the email test
Hope they will help you too
Furthermore, if I could suggest one thing:
I see the
CNAME ftp, which goes to
domain.ir, while the domain.ir is proxied - meaning, I am not sure if it will connect and pass through as expected, even when transferring the files.
Kindly, if using ftp.domain.ir hostname to access your server using an FTP application like FileZilla, it would be good way to remove that
CNAME ftp and rather create
A ftp and point it to the IP and make sure it’s - similar to the
Otherwise, I actually recommend removing it and access the FTP via directly entering the IP address rather than the hostname itself - only you know the IP
Of course, this could be different if more users need to access it, so it easy for them to remember (if they didn’t saved it)
Just an idea
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.