开发者

block sending emails that are not from a specific domain

开发者 https://www.devze.com 2023-02-21 00:31 出处:网络
I would like to filter emails sent. Emails are sent with the PHP mail() function. I would like,开发者_运维问答 without modifying any PHP file if possible, to let emails out only emails that are to a s

I would like to filter emails sent. Emails are sent with the PHP mail() function. I would like,开发者_运维问答 without modifying any PHP file if possible, to let emails out only emails that are to a specific domain, and not others. I don't have access to the SMTP server.


Just in case this helps someone ... If the emails are sent after a form is submitted (or similar action), you could change the action attribute of the form html element to point to a new php file that acts as a filter. Once passed (if so) you redirect to the "proper" destination to send the emails. The filtering could be something as easy as:

$good = "*@mydomain.foo, *@localhost";

$good = explode(',', $good);

if (pattern_grep($_POST['email'], $good)) {
   // action
}


You should be able to look at the associative array for the "to" field and use the php regex class to match domains that you blacklist.

0

精彩评论

暂无评论...
验证码 换一张
取 消