Custom & cPanel SMTP Setup: Self-Hosted Email Servers (2026)
Any SMTP server works. Match host, port, and encryption — the rest is identical.

TL;DR
- check_circleAny SMTP server speaks the same RFC 5321 protocol — host, port, encryption, username, password is all you need.
- check_circleMost cPanel/Plesk/Mailcow hosts: SMTP on mail.yourdomain.com (or smtp.yourdomain.com), port 587 STARTTLS or 465 SSL.
- check_circlePort 25 is almost always blocked outbound by residential and cloud ISPs — don't use it for client-to-server auth.
- check_circleSelf-signed certificate errors are common on freshly installed servers — install Let's Encrypt (free) and they vanish.
- check_circleAlways verify SPF, DKIM, and DMARC are set up before going live — without them, your messages land in spam.
Connection settings
mail.yourdomain.com (varies by host)587STARTTLSFull email address (you@yourdomain.com)Your mailbox passwordWhat you'll need
A mail server you control
cPanel/Plesk shared hosting, a self-hosted Mailcow/Mail-in-a-Box instance, a Postfix VPS, a Microsoft Exchange Server — anything that accepts authenticated SMTP submissions.
Mailbox credentials
A real mailbox username (usually the full email address) and password. SMTP-AUTH is required for outbound on every modern server.
DNS access
You'll want to set up SPF, DKIM, and DMARC for the sending domain. Without them, expect every message to land in spam.
Step-by-step setup
- 1
Find your SMTP host
Common conventions: mail.yourdomain.com, smtp.yourdomain.com, mail.yourhostingcompany.com. cPanel users: open Email Accounts → click "Connect Devices" → the page lists the exact hostname for your account.
lightbulbTip: Some shared hosts give you a generic hostname like smtp.bluehost.com or mail.dreamhost.com. Use the host your provider documents — don't assume mail.yourdomain.com works.
- 2
Pick the right port and encryption
Port 587 with STARTTLS is the modern standard (RFC 6409 submission). Port 465 with implicit SSL/TLS also works and is technically older. Port 25 is for server-to-server only and is blocked by most ISPs outbound — never use it for authenticated submission.
warningWatch out: If your client only offers "Use SSL" without TLS options, that's 465. If it offers TLS as an upgrade, that's STARTTLS on 587.
- 3
Use your full email as username
On cPanel/Plesk and most hosting providers, the SMTP username is the FULL email address (you@yourdomain.com), not just "you". The password is your mailbox password.
- 4
Check the TLS certificate
Self-hosted servers often serve self-signed certificates by default — which most SMTP clients reject. The fix: install a real cert (Let's Encrypt is free and auto-renewing on cPanel, Mailcow, Mail-in-a-Box, EasyEngine, and similar stacks).
lightbulbTip: Need to bypass cert validation temporarily for testing? Most clients have a "don't verify TLS certificate" toggle. Never use it in production.
- 5
Set up SPF
Add a TXT record at the root of your domain: v=spf1 ip4:YOUR_SERVER_IP include:hostingmail.com ~all. The exact value depends on your host — check their docs. SPF tells recipients which IPs are authorized to send for your domain.
- 6
Set up DKIM
Most hosts generate the DKIM private/public key pair for you. In cPanel: Email Deliverability → Manage → "Repair" button. Mailcow/Mail-in-a-Box: built into the admin UI. Postfix: install OpenDKIM and add the public key as a TXT record.
- 7
Set up DMARC
TXT record at _dmarc.yourdomain.com with value v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com. Start with p=none (monitoring), graduate to p=quarantine and p=reject after a few weeks of clean reports.
- 8
Use these SMTP server settings
Host: mail.yourdomain.com (or as documented by your host) · Port: 587 STARTTLS (or 465 SSL/TLS) · Username: full email · Password: mailbox password.
Connect to CodeOpx Mail
Connect your custom SMTP to CodeOpx Mail:
- 1Add SMTP config
Dashboard → SMTP → "Add config" → choose Custom / cPanel / self-hosted. Manually enter the host, port, encryption, username, and password from your provider.
- 2Test the handshake
Click "Test connection." Most issues at this stage: wrong port, wrong encryption (STARTTLS vs SSL), or self-signed cert.
- 3Send a test message
Compose to yourself or a Mail-Tester address (mail-tester.com gives you a one-time email + free deliverability score).
- 4Verify SPF/DKIM/DMARC
Look at the raw headers of your test message. Authentication-Results should show spf=pass, dkim=pass, dmarc=pass. If any fail, fix DNS before sending real messages.
Common errors & fixes
Self signed certificate in certificate chainTLS handshake failed
Your server's cert isn't signed by a trusted CA.
Fix: Install Let's Encrypt (free, auto-renewing). On cPanel: AutoSSL. On Mailcow: built-in. On Postfix: certbot-auto. Avoid disabling cert validation in production.
Connection timed out / refusedPort blocked or wrong
Your outbound traffic to that port is blocked, or the server isn't listening on it.
Fix: Try port 465 if 587 fails (and vice-versa). Check your ISP doesn't block outbound 25/587/465 — many residential ISPs do. From a server: telnet your.host 587 to test.
535 5.7.8 Authentication credentials invalidWrong username/password
Most often: just the local part of the email used as username instead of the full address.
Fix: Use the FULL email as username (you@yourdomain.com, not just you). Reset the mailbox password if you're unsure.
550 5.7.1 Relay access deniedServer doesn't trust you to relay
The server accepted your auth but won't accept the From address — usually a mismatched domain.
Fix: Make sure the From address is on a domain your server is authoritative for. Check Postfix's mydestination, virtual_mailbox_domains, or cPanel's domain list.
451 4.3.0 Mail server errorServer is rate-limiting you
cPanel + WHM has a per-hour cap (default 500). Shared hosts often cap to 100–500/hour.
Fix: Check WHM → Server Configuration → Tweak Settings → "Max hourly emails per domain." Bump if you're the host, or contact support to raise it. For higher volume, switch to a transactional ESP.
Sending limits
Self-hosted limits depend entirely on your stack. Shared hosting commonly caps at 100–500/hour to prevent abuse. Dedicated servers can send tens of thousands/hour given proper IP warming.
| cPanel default | 500 emails / hour / domain (configurable in WHM) |
| Plesk default | Unlimited, but provider often caps at hosting level |
| DigitalOcean droplet | Outbound port 25 blocked for new accounts; 587/465 fine |
| AWS EC2 | Outbound port 25 throttled by default; request removal via support |
| Google Cloud | Outbound 25 permanently blocked; use 587/465 with relay |
| Residential ISPs | Almost always block outbound 25; usually fine on 587/465 |
- lightbulbIf your hosting provider caps email at 100/hour and you need more, don't hammer them — switch to a transactional ESP for the volume traffic and keep the shared host for low-volume staff mail.
- lightbulbAlways set up SPF + DKIM + DMARC before sending real mail. Recipients increasingly reject unauthenticated mail outright.
- lightbulbTest your setup with mail-tester.com — it scores deliverability 0–10 and explains every deduction.
FAQ
Should I run my own mail server in 2026?
add
Honestly, mostly no. Modern spam filters are deeply hostile to small unwarmed IPs — even with perfect DNS, your messages may land in spam for months. Run your own server only if you have a strong reason (regulatory, learning, hobby). Otherwise, pay $0–20/mo to a transactional ESP and skip the operational burden.
Is port 25 the same as port 587?
add
No. Port 25 is SMTP-to-SMTP (server-to-server, MX delivery). Port 587 is the submission port for clients authenticating to send (RFC 6409). Modern clients should always submit on 587 or 465 — port 25 outbound is blocked by most ISPs anyway.
STARTTLS vs SSL/TLS — which is more secure?
add
Both are equally secure when implemented correctly. STARTTLS (port 587) begins unencrypted, then upgrades. SSL/TLS (port 465) is encrypted from the first byte. The risk with STARTTLS is theoretical man-in-the-middle stripping the upgrade — but modern clients verify the upgrade happened and abort if it didn't. Use whichever your server prefers.
Why are my self-hosted emails landing in Gmail's spam folder?
add
Multiple reasons: (1) IP reputation — fresh IPs are cold and Gmail distrusts them for weeks/months; (2) Missing SPF/DKIM/DMARC — fix this first, it's the lowest-hanging fruit; (3) Reverse DNS (PTR) — your sending IP must resolve to a hostname matching your sending domain; (4) Bulk patterns — sending bursts of similar mail to many Gmail users looks like marketing.
Can I use Cloudflare's free DNS to host SPF/DKIM records?
add
Yes — Cloudflare is excellent for email DNS. Their TXT record editor handles long DKIM values automatically, propagation is instant globally, and rate-limit protection helps. Free tier is all you need for DNS-only.
What's the difference between mail-tester.com and Postmark's spam scorer?
add
Both score deliverability. Mail-tester gives a 0–10 score and explains each deduction (free, no signup). Postmark's spam check is similar but inside their UI. Use mail-tester for one-off checks, integrate Postmark's or your own ESP's diagnostics for ongoing monitoring.
Should I install Let's Encrypt manually or use Certbot?
add
Certbot is the standard — auto-renewing, supports most servers (Postfix, Dovecot, nginx, Apache), and has hands-off automation. cPanel and Mailcow bundle it. Manual installation works but you'll forget to renew, the cert will expire, SMTP will break — happens to everyone eventually.
Video tutorial
Watch: cPanel & Postfix SMTP setup tutorials on YouTube
We curated a YouTube search of recent walkthroughs by independent creators. The official docs (linked below) remain the source of truth.
play_arrowWatch on YouTubeFurther reading
Related provider guides
Ready to send through your own server?
Sign up for CodeOpx Mail, add this SMTP config, and you'll be sending tracked emails in under 5 minutes.



