# Why mail from your PHP script or application fails
Source: https://docs.webgee.com/en/email/why-am-i-not-able-to-send-mail-via-my-php-script-or-application



If your contact form, WooCommerce store or web application cannot send email,
the cause is almost always PHP's built-in `mail()` function. Applies to shared,
reseller and cPanel hosting.

`mail()` is **disabled by default** on WebGee servers.

## Why it is disabled [#why-it-is-disabled]

`mail()` hands a message straight to the server with no authentication. The
server has no way to confirm the sender is who the message claims, so it stamps
the message with the account's own system address — something like
`youruser@server.webgee.com`.

Your application, meanwhile, has been configured to send *from*
`you@yourdomain.com`. The result is a message whose envelope sender and visible
**From** address disagree, which is exactly the pattern spam filters use to
identify spoofing. Even when such mail is accepted, it lands in Junk.

It also cannot be authenticated by SPF or DKIM for your domain, so
[DMARC](/en/email/publishing-dmarc-records-on-your-cpanel-domain) will fail it.

## Send through SMTP instead [#send-through-smtp-instead]

SMTP authenticates with a real mailbox before sending. The message is then
genuinely *from* that address, passes SPF and DKIM, and is delivered normally.

You need:

1. **A mailbox to send from.** Create one in cPanel if it does not exist — see
   [Create email accounts in cPanel](/en/email/how-to-create-email-accounts-in-cpanel).
2. **The server settings** from
   [Email server settings](/en/email/manual-configuration).
3. **The application configured to use them.**

Use port **465 with SSL/TLS**, or **587 with STARTTLS**. The username is the
**full email address**, not the part before the `@`.

### WordPress [#wordpress]

WordPress has no SMTP settings of its own. Install an SMTP plugin — WP Mail SMTP
and FluentSMTP are both widely used — and enter the settings there. Send a test
message from the plugin before assuming it works.

### Laravel, Symfony and other frameworks [#laravel-symfony-and-other-frameworks]

Set the mail transport to `smtp` in your environment configuration rather than
`sendmail` or `mail`, then supply host, port, encryption, username and password.

### Contact form and CRM applications [#contact-form-and-crm-applications]

Most have an SMTP option in their settings. Look for "outgoing mail",
"SMTP" or "mail transport" and switch it away from PHP mail or sendmail.

<Callout type="info">
  Mail sent through SMTP still counts towards your
  [hourly sending limit](/en/email/email-sending-limits). If your application
  sends a high volume of transactional mail, use a third-party SMTP relay
  instead, which keeps it off the shared quota entirely.
</Callout>

## If you genuinely need PHP mail() [#if-you-genuinely-need-php-mail]

It can be enabled on request, but you will inherit the deliverability problems
described above. See
[Enable PHP mail on your account](/en/email/enabling-phpmail-on-your-account).

## Verify [#verify]

* The application's own test-email function succeeds.
* The message arrives in the inbox rather than Junk.
* The message headers show your domain in the envelope sender, not the server
  hostname — see
  [Read email headers](/en/email/how-to-obtain-email-headers-a-step-by-step-guide).

## Related [#related]

* [Email server settings](/en/email/manual-configuration)
* [Enable PHP mail on your account](/en/email/enabling-phpmail-on-your-account)
* [Email sending limits](/en/email/email-sending-limits)
