CodeIgniter注册邮件异常求助:提示发送成功但Gmail未收到
I’ve run into similar deliverability issues with CodeIgniter’s email library and Gmail before—let’s break down the most likely fixes for your problem:
1. First, Debug the Email Sending Process
Your code shows the "email sent" success message, but we need to confirm if there’s an underlying error that’s not being caught. Add debug output right after the send() call to see exactly what’s happening:
$send = $this->email->send(); // Temporarily add this to view detailed errors echo $this->email->print_debugger(); exit; // Stop execution to see the debug info
This will reveal if sendmail is failing silently, or if there’s an authentication/configuration issue you’re missing.
2. Switch to SMTP (More Reliable for Gmail)
The sendmail protocol can be inconsistent, especially with Gmail’s strict spam filters. Using SMTP directly with Gmail’s servers will give you better deliverability and clearer error messages. Update your config to use SMTP:
$config = array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.gmail.com', 'smtp_port' => 587, 'smtp_crypto' => 'tls', 'smtp_user' => 'your-gmail-address@gmail.com', 'smtp_pass' => 'your-app-password', // Use app password if 2FA is enabled 'mailtype' => 'html', 'charset' => 'utf-8', 'wordwrap' => TRUE, 'newline' => "\r\n" // Critical for SMTP formatting ); $this->load->library('email', $config); // Rest of your email setup (subject, message, from/to) stays the same
Key Gmail SMTP Notes:
- If you have 2FA enabled on your Gmail account, generate an App Password (Google Account > Security > App Passwords) instead of your regular password.
- Without 2FA, you’ll need to enable "Less secure app access" (though Google recommends using 2FA + App Passwords for better security).
3. Check Gmail’s Spam/Promotions Tabs
Even if the email sends successfully, Gmail might route it to Spam or Promotions instead of your Primary inbox. Double-check those folders—legitimate verification emails often get flagged there, especially if the sender domain is new or lacks proper authentication.
4. Improve Sender Domain Authentication
Since you’re using info@techeasesol.com as the sender, make sure your domain has DKIM and SPF records set up. These DNS records validate that your email is legitimate and not spam. Most domain hosts have built-in tools to configure these easily.
5. Verify Sendmail Setup (If You Want to Keep Using It)
If you prefer sticking with sendmail:
- Confirm sendmail is installed and running on your server.
- Test sending an email from the command line using
sendmailto rule out server-level issues. - Check if your server’s IP is blacklisted (use tools like MXToolbox to verify).
Try these steps one by one—starting with debugging and switching to SMTP is usually the fastest way to resolve Gmail deliverability issues.
内容的提问来源于stack exchange,提问作者Salman Iqbal

