import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; import {Button} from 'sentry/components/button'; import {t} from 'sentry/locale'; import {useApiQuery, useMutation} from 'sentry/utils/queryClient'; import useApi from 'sentry/utils/useApi'; type MailData = { mailFrom: string; mailHost: string; mailListNamespace: string; mailPassword: string; mailPort: string; mailUseSsl: string; mailUseTls: string; mailUsername: string; testMailEmail: string; }; export default function AdminMail() { const api = useApi(); const {data, isLoading} = useApiQuery(['/internal/mail/'], {staleTime: 0}); const {mutate: sendTestEmail} = useMutation({ mutationFn: () => api.requestPromise('/internal/mail/', {method: 'POST'}), onSuccess: () => { addSuccessMessage(t('A test email has been sent to %s', testMailEmail)); }, onError: () => { addErrorMessage(t('Unable to send test email. Check your server logs')); }, }); if (isLoading || !data) { return null; } const { mailFrom, mailHost, mailPort, mailUsername, mailPassword, mailUseTls, mailUseSsl, 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." )}

); }