yikart/AiToEarn · error · AppHttpException
ErrHttpBack.err_mail_send_fail
ErrHttpBack.err_mail_send_fail
Error message
err_mail_send_fail
What it means
err_mail_send_fail is thrown during email-registration (loginByMail regist flow) when mailService.sendEmail returns falsy, meaning the registration email with the confirmation link could not be sent. The registration attempt is aborted and the client is told mail delivery failed.
Source
Thrown at project/aitoearn-electron/server/src/user/userLogin.controller.ts:440
}
// 没有进行创建逻辑
const code = getRandomString(6, true);
this.redisService.setKey(
`userMailLogin:${code}`,
{ mail: mail, status: 0 },
60 * 5,
);
// 发验证码邮件,邮箱号和code
const mailRes = await this.mailService.sendEmail({
to: mail,
subject: 'aitoearn regist',
html: `<a href="https://api.aitoearn.cn/api/user/login/mail/regist/url?mail=${mail}&code=${code}">点击此处进行注册</a>`,
});
if (!mailRes) throw new AppHttpException(ErrHttpBack.err_mail_send_fail);
return {
type: 'regist',
code: code,
};
}
// TODO: 后期改成返回页面
@ApiOperation({
summary: '邮箱注册',
description: '用户点击链接后,进行注册',
})
@Public()
@Get('mail/regist/url')
async registByMail(
@Query(new ParamsValidationPipe()) query: MailRegistUrlDto,
) {
const { mail, code } = query;View on GitHub (pinned to d3aa8bea5b)
Solutions
- Check the mailService/SMTP configuration env vars (host, port, auth) in the running environment
- Send a test email through the same mailService to isolate the failure
- Verify network egress allows SMTP to the mail provider, and check provider quota/bounce logs
- If using a sandbox/dev environment, confirm the mail provider account is active and the recipient address is valid
Example fix
// before // .env: SMTP_HOST=, SMTP_USER= (empty) // after // .env: SMTP_HOST=smtp.example.com, SMTP_PORT=465, SMTP_USER=noreply@example.com, SMTP_PASS=*** // then restart the server and retry registration
Defensive patterns
Strategy: fallback
Validate before calling
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(mail)) {
showFormError('Invalid mail address');
return;
} Try / catch
try {
await api.startMailRegistration(mail);
} catch (e) {
if (e.response?.data?.code === 'err_mail_send_fail') {
showRetryBanner('Registration email could not be sent. Check your address or retry later.');
return;
}
throw e;
} Prevention
- Verify SMTP env vars (host, port, credentials) on every deployment
- Send a startup health-check email to catch mail misconfiguration early
- Monitor mail provider bounce/quota dashboards
- Validate recipient addresses client-side before triggering registration emails
When it happens
Trigger: POST initiating mail registration where the underlying mail delivery call fails or reports failure: SMTP misconfiguration, invalid/expired mail provider credentials, unreachable SMTP host, rejected recipient address, or mailService returning false on error instead of throwing.
Common situations: Missing or wrong SMTP env vars (host/port/user/pass) in a deployment; mail provider credentials rotated or quota exhausted; recipient domain hard-bouncing; firewall blocking outbound SMTP ports (25/465/587).
Related errors
- InvalidModel
- InvalidModel
- image aspectRatio cannot be converted to a supported size
- ResponseCode.ChannelAccountCreateNotSupported
- ChannelAuthorizationFailed
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/157ca685248d91ba.
Report an issue: GitHub.