Is it possible to configure PHP to only send emails created using mail() to a specific list of whitelisted domains? E.g. An email to johndoe@domain1.com is sent because domain1.com is on the whitelist but a mail to johndoe@domain2.com is dropped because domain2.com is not. Even when the email itself is properly formed with correct headers.

PHP version 5.2.17


I think you are trying to prevent people sending spam, unfortunately people will always find a way to send mail from php. Even if you are able to limit the mail() function, nothing will prevent them from writing an own implementation that opens a socket.

So in short, there is no way to enforce this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.