🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Sending Emails from GoDaddy VPS with cPanel + WHM

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

ComponentRole
EximThe default Mail Transfer Agent (MTA)
PHPUses Exim via /usr/sbin/sendmail for mail()
WHMManages global email delivery, logs, limits
cPanelManages 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.";
}
?>

Save this as mailcheck.php inside your website’s public_html folder.

🔹 Step 2: Access in Browser

Visit:

https://yourdomain.com/mailcheck.php

You should see “✅ Email sent successfully.”


🔍 3. Check Email Logs

SSH into the VPS:

sudo tail -f /var/log/exim_mainlog

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

  1. Go to WHM > Email > Email Deliverability
  2. Choose your domain
  3. Click “Repair” if SPF or DKIM are missing
  4. 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

✉️ 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:

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;
}

🛠️ 6. Common Issues & Troubleshooting

ProblemSolution
mail() fails silentlyCheck /var/log/exim_mainlog
Mail lands in spamSetup SPF/DKIM/DMARC correctly
Mail delivery delaysCheck WHM > Mail Queue Manager
PHP can’t find sendmailEnsure /usr/sbin/sendmail exists (default in WHM)
SMTP auth failsDouble-check credentials, port 587 with TLS
GoDaddy blocking portsVPS 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-Unsubscribe headers 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/FeatureWhere
Email AccountscPanel
Mail Logs/var/log/exim_mainlog
DNS SettingsWHM > Email Deliverability
Webmail Accesshttps://yourdomain.com/webmail
Mail QueueWHM > Mail Queue Manager
SMTP CredentialscPanel > Email Accounts

Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
reCaptcha Error: grecaptcha is not defined

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x