import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; import {Button} from 'sentry/components/button'; import {t} from 'sentry/locale'; import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView'; type Data = { mailFrom: string; mailHost: string; mailListNamespace: string; mailPassword: string; mailPort: string; mailUseSsl: string; mailUseTls: string; mailUsername: string; testMailEmail: string; }; type State = DeprecatedAsyncView['state'] & {data: Data}; export default class AdminMail extends DeprecatedAsyncView<{}, State> { getEndpoints(): ReturnType { return [['data', '/internal/mail/']]; } sendTestEmail = async () => { const testMailEmail = this.state.data.testMailEmail; try { await this.api.requestPromise('/internal/mail/', {method: 'POST'}); addSuccessMessage(t('A test email has been sent to %s', testMailEmail)); } catch (error) { addErrorMessage( error.responseJSON ? error.responseJSON.error : t('Unable to send test email. Check your server logs') ); } }; renderBody() { const {data} = this.state; const { mailHost, mailPassword, mailUsername, mailPort, mailUseTls, mailUseSsl, mailFrom, mailListNamespace, testMailEmail, } = data; return (

{t('SMTP Settings')}

{t('From Address')}
{mailFrom}
{t('Host')}
              {mailHost}:{mailPort}
            
{t('Username')}
{mailUsername || {t('not set')}}
{t('Password')}
              {mailPassword ? '********' : {t('not set')}}
            
{t('STARTTLS?')}
{mailUseTls ? t('Yes') : t('No')}
{t('SSL?')}
{mailUseSsl ? t('Yes') : t('No')}
{t('Mailing List Namespace')}
{mailListNamespace}

{t('Test Settings')}

{t( "Send an email to your account's email address to confirm that everything is configured correctly." )}

); } }