ShipFree provides robust email functionality through Mailgun integration, offering both transactional and marketing email capabilities.
Add your Mailgun credentials to .env
:
MAILGUN_API_KEY=your_api_key
MAILGUN_DOMAIN=your_domain
MAILGUN_FROM_EMAIL=noreply@yourdomain.com
Built-in templates for common scenarios:
ShipFree uses React Email for beautiful, responsive templates:
// emails/WelcomeEmail.tsx
import {
Body,
Container,
Head,
Heading,
Html,
Text,
} from "@react-email/components";
export const WelcomeEmail = ({ name }: { name: string }) => (
<Html>
<Head />
<Body>
<Container>
<Heading>Welcome to Our App!</Heading>
<Text>Hi {name}, we're excited to have you on board!</Text>
</Container>
</Body>
</Html>
);
Simple API for sending emails:
import { sendEmail } from "@/lib/email";
// Send a single email
await sendEmail({
to: "user@example.com",
subject: "Welcome!",
template: "welcome",
variables: {
name: "John",
},
});
// Send bulk emails
await sendBulkEmails({
recipients: ["user1@example.com", "user2@example.com"],
subject: "Newsletter",
template: "newsletter",
variables: {
content: "Latest updates...",
},
});
Email Deliverability
Template Design
Content Guidelines
Authentication
Account Updates
Orders
Newsletters
Promotional
Track email performance:
// Configure test mode
if (process.env.NODE_ENV === "development") {
// Emails will be logged instead of sent
useTestMailgun();
}
Preview emails during development:
npm run email-preview
Common issues and solutions:
Delivery Issues
Template Problems
API Errors