Joshua
Joshua

Reputation: 279

Flutter: mailer

In my app I am using mailer for feeback, if user wants to send. Its working as expected, but only problem is password is visible in plain text. How can I improve this without showing my password or any better alternatives? Your suggestions and recommentaions are most welcome and thanks in advance

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

  String username = ‘[email protected]';
  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}');
    }
  }
}

Upvotes: 1

Views: 193

Answers (1)

Akif
Akif

Reputation: 7640

There is a package, flutter_secure_storage. You can use this for passwords.

 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);

Upvotes: 0

Related Questions