Flutter:发送电子邮件

时间:2019-08-27 10:03:32

标签: flutter dart

我几乎不问有关发送电子邮件的问题。我使用https://pub.dev/packages/flutter_email_sender#-readme-tab-发送电子邮件。

发送功能

Future sendEmail(String subject,String body,List<String> recipients) async{
    final Email email = Email(body: body,subject: subject,recipients: recipients);
    String platformResponse;
    try {
      await FlutterEmailSender.send(email);
      platformResponse='success';
    } catch (e) {
      platformResponse = e.toString(); 
    }
    print(platformResponse);
  }

View.dart

Center(
    child: RaisedButton(
    onPressed: () => _sendMail(),
    child: Text('send'),
  ),
)
void _sendMail() async {
    return await api.sendEmail(widget.namaUpdate, widget.jurusanUpdate,['zefry.reynando@gmail.com']);
  }

有可能不先打开gmail应用程序就自动发送电子邮件吗? (类似于codeigniter)

我尝试使用其他程序包,但始终先打开gmail应用程序。还是这样?

谢谢

1 个答案:

答案 0 :(得分:0)

您不太可能找到没有配置或没有可见邮件客户端的发送电子邮件的软件包。该应用程序可能不会被Apple或Google批准,因为它可能是垃圾邮件的来源。