颤振:邮件

时间:2020-10-13 16:56:58

标签: flutter mailer

在我的应用程序中,如果用户要发送邮件,我正在使用邮寄程序进行退款。它可以正常工作,但唯一的问题是密码以纯文本形式可见。在不显示密码或其他更好的选择的情况下,我该如何改善呢?非常欢迎您提出建议和建议

void sendmail() async {
  final myFeedback = TextEditingController();

  String username = ‘mymail@gmail.com';
  String password = ‘my password’;
  final smtpServer = gmail(username, password);
  final message = Message()
    ..from = Address(username, email)
    ..recipients.add(username)
    ..subject = 'FeedBack '
    ..html = "<h1>FeedBack:</h1>\n<h3>$feed</h3>";
  try {
    var sendReport = PersistentConnection(smtpServer);
    await sendReport.send(message);
    await sendReport.close();
    print('Message sent: ' + sendReport.toString());
  } on MailerException catch (e) {
    print('Message not sent.');
    for (var p in e.problems) {
      print('Problem: ${p.code}: ${p.msg}');
    }
  }
}

1 个答案:

答案 0 :(得分:0)

有一个软件包flutter_secure_storage。您可以将其用作密码。

 import 'package:flutter_secure_storage/flutter_secure_storage.dart';

 // Create storage
 final storage = new FlutterSecureStorage();

 // Read value 
 String value = await storage.read(key: key);

 // Read all values
 Map<String, String> allValues = await storage.readAll();

 // Delete value 
 await storage.delete(key: key);

 // Delete all 
 await storage.deleteAll();

 // Write value 
 await storage.write(key: key, value: value);