You should swap these two conditions around to avoid having to do a regex match even if sent_to_all_checked is True
i.e.
```python
elif (not send_to all_checked) and re.match(r'[\w\.]+', recipient)
```