Test Mail
Last modified by Manuel Smeria on 2021/03/18 11:28
A quick UI to verify a SMTP setup, that allows to send easily test emails |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Restricted to admins.
{{velocity}}
#if($xwiki.hasAccessLevel('admin'))
#if("$!{request.action}" == 'send_mail' && "$!{request.lastname}" == '')
## Check submission and honey pot.
#if("$!request.recipient" != '' && "$!request.subject" != '')
#set($result = $xwiki.mailsender.sendTextMessage("[email protected]", $request.recipient, $request.subject, "$!request.message"))
#if($result == -1)
{{error}}A problem occurred while sending the mail: $context.error{{/error}}
#else
{{info}}Everything went OK.{{/info}}
#end
#else
{{error}}Please specify at least a recipient and a subject{{/error}}
#end
#end
{{html wiki=true}}
<form action="" method="post">
<input name="action" value="send_mail" type="hidden" />
## this is a honey-pot hidden text field hat hopefully robots will not leave empty
<div class="hidden">
<input name="lastname" type="text" />
</div>
<fieldset>
**TO:**<br />
<input type="text" name="recipient" /><br />
**SUBJECT:**<br />
<input type="text" name="subject" /><br />
**MESSAGE:**<br />
<textarea name="message" style="width:99%;" rows=10>Your test message here.</textarea>
</fieldset>
<div>
<span class="buttonwrapper"><input type="submit" class="button" value="Send" /></span>
</div>
</form>
{{/html}}
#else
{{error}}Oops. Area restricted to Admins, sorry.{{/error}}
#end
{{/velocity}}
#if($xwiki.hasAccessLevel('admin'))
#if("$!{request.action}" == 'send_mail' && "$!{request.lastname}" == '')
## Check submission and honey pot.
#if("$!request.recipient" != '' && "$!request.subject" != '')
#set($result = $xwiki.mailsender.sendTextMessage("[email protected]", $request.recipient, $request.subject, "$!request.message"))
#if($result == -1)
{{error}}A problem occurred while sending the mail: $context.error{{/error}}
#else
{{info}}Everything went OK.{{/info}}
#end
#else
{{error}}Please specify at least a recipient and a subject{{/error}}
#end
#end
{{html wiki=true}}
<form action="" method="post">
<input name="action" value="send_mail" type="hidden" />
## this is a honey-pot hidden text field hat hopefully robots will not leave empty
<div class="hidden">
<input name="lastname" type="text" />
</div>
<fieldset>
**TO:**<br />
<input type="text" name="recipient" /><br />
**SUBJECT:**<br />
<input type="text" name="subject" /><br />
**MESSAGE:**<br />
<textarea name="message" style="width:99%;" rows=10>Your test message here.</textarea>
</fieldset>
<div>
<span class="buttonwrapper"><input type="submit" class="button" value="Send" /></span>
</div>
</form>
{{/html}}
#else
{{error}}Oops. Area restricted to Admins, sorry.{{/error}}
#end
{{/velocity}}