I just copied the readme file and put it into an example project, Im trying to send a email but it always have the same error.
PlatformException(not_available, No email clients found!, null, null)
There’s my code:
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Mandar Correo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Manda Correo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Title'),
centerTitle: true,
),
body: Center(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.all(20),
textStyle: TextStyle(fontSize: 24),
),
child: const Text('Enviar Correo'),
onPressed: sendMail,
),
),
);
}
}
sendMail() async {
final Email email = Email(
body: "example",
subject: "title",
recipients: ['bb@bb'],
cc: ['aaAhmad Khan Kolaachi'],
isHTML: false,
);
String platformResponse;
try {
await FlutterEmailSender.send(email);
platformResponse = 'success';
} catch (error) {
print(error);
platformResponse = error.toString();
}
}
AndroidManifest.xml, it says that Android v.11 needs some permisions. So i just copy them.
add this in AndroidManifest.xml
check here for more info