PHP mail() returns success but no delivery #175291
Replies: 5 comments
-
|
Thanks for posting in the GitHub Community, @gechjs! We're happy you're here. You are more likely to get a useful response if you are posting your question in the applicable category, the Discussions category is solely related to conversations around the GitHub product Discussions. This question should be in the |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
When 1. Check your spam/junk folder first 2. Server-side mail configuration issues
3. Missing or incorrect email headers $to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a test message.";
$headers = "From: noreply@yourdomain.com\r\n";
$headers .= "Reply-To: noreply@yourdomain.com\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to, $subject, $message, $headers);4. Check server mail logs 5. SPF, DKIM, and DMARC records Recommended Solution for GoDaddy: // Using PHPMailer with SMTP
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com'; // or your SMTP server
$mail->SMTPAuth = true;
$mail->Username = 'your-email@domain.com';
$mail->Password = 'your-password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;Can you check your server's mail logs or confirm whether your GoDaddy hosting plan supports outbound mail? That would help narrow down the issue. |
Beta Was this translation helpful? Give feedback.
-
|
The mail() function returning true only means that PHP handed the message to the server’s mail transfer agent (MTA) — not that the email was actually delivered. On GoDaddy hosting, there are a few common reasons why mail() “succeeds” but nothing arrives:
Many shared hosting plans restrict outbound mail to reduce spam. In many cases delivery silently fails even though mail() returns true.
Make sure your domain has: SPF record including GoDaddy’s sending servers DKIM (if available) DMARC (optional but recommended) Missing SPF/DKIM frequently causes messages to be rejected or sent to spam.
GoDaddy typically requires the From: header to be something like: Using Gmail or another domain often causes the mail to be dropped.
This is the most reliable fix. GoDaddy’s own SMTP or a third-party service (SendGrid, Mailgun, Amazon SES) Example (PHPMailer + SMTP) ensures actual delivery. Summary: |
Beta Was this translation helpful? Give feedback.
-
|
En este caso el problema no es el código, sino el uso de mail(). En hosting compartido (como GoDaddy), mail() suele estar limitado o bloqueado para evitar spam. Por eso ocurre este comportamiento:
La solución recomendada es no usar mail() y migrar a envío por SMTP autenticado, por ejemplo usando PHPMailer, que es el enfoque más confiable. Enfoque recomendado: no usar mail()La solución práctica es evitar mail() y enviar correos mediante SMTP autenticado, usando las credenciales reales del correo del dominio. Un ejemplo funcional con PHPMailer sería este: Instalación con Composer
Configuración típica en GoDaddy Para correos del dominio:
Además, es importante:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Discussion Type
Product Feedback
Discussion Content
Problem Description
I want to receive emails to my GoDaddy domain (webmail) with contact page, the PHP
mail()function doesn't deliver outgoing emails even though it returnstrue.Key Point: Receiving works, sending doesn't.
Beta Was this translation helpful? Give feedback.
All reactions