
Use SMTP with a real mailbox on your domain. The mail() function is fine for a quick test, but it returns “sent” only because the local mail program accepted the message, not because it arrived. With SMTP there is authentication, there are errors you can read, and the messages are far less likely to end up in spam.
The two ways, side by side
| mail() | SMTP | |
| How it leaves | Handed to the server’s mail program, with no authentication. | Your code logs in to a mailbox with a user and password and sends through it. |
| When it fails | PHP says “true” anyway. You learn nothing. | There are clear errors: wrong password, wrong port, sender refused. |
| Spam | Sender and server rarely match, which filters notice. | The sender is a mailbox on your domain, which has SPF and DKIM on its side. |
| Set-up | None in the code. | Server, port, user, password and encryption. |
Moving to SMTP
|
|
|
|
|
| An open form is a spam cannon. If your script lets whoever uses it choose the recipient, the sender or the subject without checking, someone will use it to send spam through your account, and the server ends up on a blocklist. Validate what comes from the form, and fix the recipient in the code. If it has already happened, see your server IP on a blocklist. |
| Even with the right SMTP, the domain has to be set up properly. Without SPF, DKIM and DMARC messages look suspicious: see SPF, DKIM and DMARC. There are sending limits per hour and behaviour rules: writing an e-mail that does not land in spam. And cPanel has Track Delivery, where you see where each message went. |
|
The form says “sent” and the message never arrives? Tell us the sending address, the destination and the time. Open a support ticket |
|
SEE ALSO Sending e-mail from your own code with PHPMailer A contact form that actually reaches your inbox |
RECOMMENDED PRODUCT Professional e-mail on your domain Mailboxes in your company name, no adverts, with spam filtering. from KSh858.00/mo (3-year plan, with coupon) See plans |
- 0 Users Found This Useful











