phppup Posted November 3, 2023 Share Posted November 3, 2023 (edited) I've used PHP's mail function previously and I'm thinking of using it again. At one point, I recall getting success messages when the mail function completed, but discovered that certain emails were never received by recipients. After much troubleshooting, I discovered that the shared hosting server that I was using included quota limits on outboard emails. Essentially (if my understanding is correct), the PHP confirmation was accurate, but the actual messages (after hitting the quota) were never dispatched. How can I get confirmation that the intended email actually left the server? Further, can I determine that it wasn't filtered by the recipient's email provider or tagged as spam? Edited November 3, 2023 by phppup Forgot item Quote Link to comment Share on other sites More sharing options...
ginerjm Posted November 3, 2023 Share Posted November 3, 2023 The PHP mail() function only returns a boolean based upon if the command was setup (?) properly. If you need a better response you might find more help using PHPMailer which is pretty easy to install and use. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 3, 2023 Share Posted November 3, 2023 PHPMailer will also help you send emails that are less likely to be discarded by spam filters. And it doesn't need to rely on the system's emailing configuration. But even then, you can never be totally sure that the email has actually reached its recipient. Quote Link to comment Share on other sites More sharing options...
maxxd Posted November 3, 2023 Share Posted November 3, 2023 I wouldn't use php's native mail function to be honest. PHPMailer is easier, more robust, and more reliable as both requinix and ginerjm have pointed out. That having been said, if your project requires mail stats you may be better off looking into a service. MailChimp has an API that doesn't completely suck and ConstantContact has an API - both of them have methods in place to gather interaction stats, though honestly even those can be dubious at times. Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 5, 2023 Share Posted November 5, 2023 Mail was designed to inject outgoing mail into the system MTA (mail transfer agent). Thus it has no visibility into deliverability. SMTP (the mail transfer protocol) has no insight into this either, unless the smtp connection is rejected, or the mail server returns an error message. From the php application standpoint, it just knows it dropped off mail at the post office. This is why libraries like phpmailer and symfony mailer were created, as they are designed to handle more of the process. Sending email with even a modicum of deliverability is a non-trivial task, which is one of many reasons why there are companies that take care of a lot of the problem. The mail libraries listed are also suited to integration with many of the popular remailing services (mailchimp, mailgun, sendgrid etc.) Quote Link to comment Share on other sites More sharing options...
maxxd Posted November 6, 2023 Share Posted November 6, 2023 (edited) Mailgun and Sendgrid are pretty good, yeah. Although - in my experience - even they sometimes seem like they're guessing at statistics. Edit: I realize I sound like I'm shitting on email services; I'm not. They're far more reliable than home-grown or most native solutions, but I remember a campaign I worked that reported like 80% open rate and 65% click-through on Sendgrid and I was like "uhhh ... nah, dude. I don't think so." Edited November 6, 2023 by maxxd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.