respond with mailto:some@recipient.com
- mes
- Member | 8
To hide mail addresses from scanning bots, I'd like to answer a specific http request with a redirection to an mailto: Location which lets the mail client pop up. But avoids the "mailto:"within the source-code of the page.
Usually this is simply done in a separate file e.g.
mailto.php
:
After compile the mail address,
using header('Location: mailto:some@recipient.com');
for
redirection
and then exit(1)
the script to avoid further output. Invalid
request will be answered by 404
how to implement a similar behavior within a presenter action?
And is a presenter the correct approach?
Thank you in advance!
- Marek Bartoš
- Nette Blogger | 1262
In UI\Presenter
descendant:
$this->redirectUrl('mailto:some@recipient.com')
(shortcut
for $this->sendResponse(new RedirectResponse(/* ... */))
In IPresenter::run()
implementation:
return new \Nette\Application\Responses\RedirectResponse('mailto:some@recipient.com');
Both are equal and work as a replacement for header()
and exit()
Presenter is indeed the right place for page-specific http request handling, you are going the right way :)
Last edited by Marek Bartoš (2022-01-24 01:56)