Absolutely! Here’s a comprehensive tutorial and troubleshooting guide for sending email from a GoDaddy VPS Server with cPanel + WHM. This includes PHP mail(), SMTP setup, logs, DNS settings, and common issues with solutions.
📧 Sending Emails from GoDaddy VPS with cPanel + WHM
🧩 1. How Email Sending Works on a cPanel VPS
| Component | Role |
|---|---|
| Exim | The default Mail Transfer Agent (MTA) |
| PHP | Uses Exim via /usr/sbin/sendmail for mail() |
| WHM | Manages global email delivery, logs, limits |
| cPanel | Manages email accounts and per-domain settings |
✅ 2. Send Email Using PHP’s mail() Function
🔹 Step 1: Create a PHP Script
<?php
$to = "your@email.com";
$subject = "Test Email from GoDaddy VPS";
$message = "This is a test email sent using PHP.";
$headers = "From: noreply@yourdomain.com";
if (mail($to, $subject, $message, $headers)) {
echo "✅ Email sent successfully.";
} else {
echo "❌ Email sending failed.";
}
?>
Code language: HTML, XML (xml)
Save this as mailcheck.php inside your website’s public_html folder.
🔹 Step 2: Access in Browser
Visit:
https://yourdomain.com/mailcheck.php
Code language: JavaScript (javascript)
You should see “✅ Email sent successfully.”
🔍 3. Check Email Logs
SSH into the VPS:
sudo tail -f /var/log/exim_mainlog
Code language: JavaScript (javascript)
Other useful logs:
/var/log/exim_paniclog– for fatal errors/var/log/exim_rejectlog– for rejected messages
⚙️ 4. Configure SPF, DKIM, and DMARC (Important for Delivery)
✔️ SPF & DKIM
- Go to WHM > Email > Email Deliverability
- Choose your domain
- Click “Repair” if SPF or DKIM are missing
- Copy the suggested DNS records to your GoDaddy DNS
✔️ DMARC (Optional but Recommended)
Add this TXT record in DNS:
Name: _dmarc.yourdomain.com
Type: TXT
Value: v=DMARC1; p=none; rua=mailto:you@yourdomain.com
Code language: HTTP (http)
✉️ 5. Send Email via SMTP (More Reliable)
Use this when sending emails from contact forms, apps, or Laravel/WordPress.
🔹 Create an Email Account
In cPanel > Email Accounts, create:
- Email:
info@yourdomain.com - Password:
your_password
🔹 Use PHPMailer (Example)
Install:
composer require phpmailer/phpmailer
Code language: JavaScript (javascript)
Code:
use PHPMailer\PHPMailer\PHPMailer;
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = 'mail.yourdomain.com';
$mail->SMTPAuth = true;
$mail->Username = 'info@yourdomain.com';
$mail->Password = 'your_password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('info@yourdomain.com', 'Your Name');
$mail->addAddress('recipient@example.com');
$mail->Subject = 'SMTP Test Email';
$mail->Body = 'This email is sent using SMTP and PHPMailer.';
if ($mail->send()) {
echo '✅ Mail sent!';
} else {
echo '❌ Mail failed: ' . $mail->ErrorInfo;
}
Code language: PHP (php)
🛠️ 6. Common Issues & Troubleshooting
| Problem | Solution |
|---|---|
mail() fails silently | Check /var/log/exim_mainlog |
| Mail lands in spam | Setup SPF/DKIM/DMARC correctly |
| Mail delivery delays | Check WHM > Mail Queue Manager |
| PHP can’t find sendmail | Ensure /usr/sbin/sendmail exists (default in WHM) |
| SMTP auth fails | Double-check credentials, port 587 with TLS |
| GoDaddy blocking ports | VPS is usually open, but shared hosting blocks SMTP ports |
🔐 7. Tips for Deliverability
- Use a real domain and valid “From” address (avoid
noreply@localhost) - Keep your IP clean (avoid spamming)
- Use
List-Unsubscribeheaders for bulk email - Monitor bounces and complaints
🧪 8. Bonus: Webmail Testing
You can also send test emails from:
- Webmail: Access via
https://yourdomain.com/webmail - Login with the email you created in cPanel
🧰 Tools Recap
| Tool/Feature | Where |
|---|---|
| Email Accounts | cPanel |
| Mail Logs | /var/log/exim_mainlog |
| DNS Settings | WHM > Email Deliverability |
| Webmail Access | https://yourdomain.com/webmail |
| Mail Queue | WHM > Mail Queue Manager |
| SMTP Credentials | cPanel > Email Accounts |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at WIZBRAND