import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; import {Button} from 'sentry/components/button'; import LoadingError from 'sentry/components/loadingError'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import {t} from 'sentry/locale'; import {useApiQuery} from 'sentry/utils/queryClient'; import useApi from 'sentry/utils/useApi'; type Data = { mailFrom: string; mailHost: string; mailListNamespace: string; mailPassword: string; mailPort: string; mailUseSsl: string; mailUseTls: string; mailUsername: string; testMailEmail: string; }; export default function AdminMail() { const {data, isPending, isError, refetch} = useApiQuery(['/internal/mail/'], { staleTime: 0, }); const api = useApi({persistInFlight: true}); if (isPending) { return ; } if (isError) { return ; } const { testMailEmail, mailHost, mailPassword, mailUsername, mailPort, mailUseTls, mailUseSsl, mailFrom, mailListNamespace, } = data; const sendTestEmail = async () => { try { await 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') ); } }; 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." )}

); }