⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
import { sendEmail, type EmailConfig, type EmailMessage } from '@repo/mailer';
import { HttpError } from '#shared/lib';
// Provider errors can contain host names and transport details that should stay
// in the server log. Map only recognizable categories to actionable, stable API
// messages and use a generic fallback for everything else.
export function emailTestError(error: string | undefined): string {
const value = error?.toLowerCase() ?? '';
if (value.includes('timeout') || value.includes('aborted')) {
return 'The email provider timed out';
}
if (value.includes('429') || value.includes('rate limit') || value.includes('quota')) {
return 'The email provider rate limit or quota was reached';
}
if (
value.includes('sender') ||
value.includes('from address') ||
value.includes('domain is not verified') ||
value.includes('verify a domain') ||
value.includes('domain verification')
) {
return 'The email provider rejected the From address';
}
if (
value.includes('auth') ||
value.includes('credential') ||
value.includes('invalid login') ||
value.includes('401') ||
value.includes('403') ||
value.includes('535')
) {
return 'The email provider rejected the credentials';
}
return 'The email provider rejected the test message';
}
export async function deliverTestEmail(config: EmailConfig, message: EmailMessage): Promise<void> {
const result = await sendEmail(
{ ...config, smtp: { ...config.smtp, timeout: config.smtp.timeout ?? 15 } },
message,
);
if (!result.ok) {
console.error('[god] test email failed:', result.error);
throw new HttpError(502, emailTestError(result.error));
}
}