السلام عليكم اعمل على تطبيق فلاتر هل يوجد طريقة لاارسال رسائل الى ايميلات yahoo
شكرا مقدما
ما ستحتاجه هو:
بعد تثبيت المكتبة:
dependencies: flutter_mailer: ^2.0.0
عليك استيرادها:
import 'package:flutter_mailer/flutter_mailer.dart';
ثم إرسال رسالة بريد إلكتروني:
import 'package:flutter_mailer/flutter_mailer.dart';
...
...
final MailOptions mailOptions = MailOptions(
body: 'a long body for the email <br> with a subset of HTML',
subject: 'the Email Subject',
recipients: ['example@example.com'],
isHTML: true,
bccRecipients: ['other@example.com'],
ccRecipients: ['third@example.com'],
attachments: [ 'path/to/image.png', ],
);
final MailerResponse response = await FlutterMailer.send(mailOptions);
switch (response) {
case MailerResponse.saved: /// ios only
platformResponse = 'mail was saved to draft';
break;
case MailerResponse.sent: /// ios only
platformResponse = 'mail was sent';
break;
case MailerResponse.cancelled: /// ios only
platformResponse = 'mail was cancelled';
break;
case MailerResponse.android:
platformResponse = 'intent was successful';
break;
default:
platformResponse = 'unknown';
break;
}
بالطبع عليك استبدال القيم التالية بما تريد:
body: 'a long body for the email <br> with a subset of HTML', subject: 'the Email Subject', recipients: ['example@example.com'], isHTML: true, bccRecipients: ['other@example.com'], ccRecipients: ['third@example.com'], attachments: [ 'path/to/image.png', ],
وفي نظام الأندرويد تستطيع تفقد هل تطبيق معين مثبت مثل GMAIL كالتالي:
const GMAIL_SCHEMA = 'com.google.android.gm';
final bool gmailinstalled = await FlutterMailer.isAppInstalled(GMAIL_SCHEMA);
if(gmailinstalled) {
final MailOptions mailOptions = MailOptions(
body: 'a long body for the email <br> with a subset of HTML',
subject: 'the Email Subject',
recipients: ['example@example.com'],
isHTML: true,
bccRecipients: ['other@example.com'],
ccRecipients: ['third@example.com'],
attachments: [ 'path/to/image.png', ],
appSchema: GMAIL_SCHEMA,
);
await FlutterMailer.send(mailOptions);
}
وستجد تفصيل أكثر بالمستند الرسمي:
وتتوفر مكتبات أخرى لإرسال رسائل البريد الإلكتروني، مثل mailer و dart_smtp.
التعليقات