SMTP (Simple Mail Transfer Protocol)
A lightweight, pure Dart solution to send emails directly via SMTP without any third-party dependencies. Perfect for Flutter and Dart applications that need simple, programmatic email sending.
Use Exmaple
import 'dart:io';
import 'package:smtp_service/smtp.dart';
void main() async {
// 1️⃣ إنشاء الخدمة مع بيانات تسجيل الدخول
final smtpService = SMTPService(
username: "ahmed@gmail.com",
password: "password",
);
// 2️⃣ إضافة المستلمين (Observers)
smtpService.attach(
Recipient("mostafa@gmail.com", RecipientType.to),
);
smtpService.attach(
Recipient("mohamed@gmail.com", RecipientType.to),
);
// 3️⃣ إنشاء الإيميل نفسه
final email = EmailBuilder()
.from(
const MailAddress(
address: "ahmed@gmail.com",
name: "Ahmed Wael",
),
)
.subject("Test Email from Dart")
.message("This is a simple test email sent using pure Dart SMTP service.")
.build();
// 4️⃣ إزالة أحد المستلمين قبل الإرسال
smtpService.detach(
Recipient("ahmedwael99104@gmail.com", RecipientType.to),
);
// 5️⃣ إرسال الإيميل
print("📤 Sending email...");
await smtpService.sendEmail(email);
print("✅ Email sent successfully!");
}
Author
Ahmed Wael
Flutter Developer
Passionate about building modern, scalable apps