flutteremailmail-sender

Sending Email in Flutter Web without a Backend


I'm working on a Flutter web application and need to implement email sending functionality directly from the client side without using a backend server. I don't have a backend and would like to explore options within Flutter web itself.

I've looked into mailer library, but I'm unsure about the best way to achieve this without compromising security.

Specific Questions:

Is it possible to send emails directly from a Flutter web app without a backend? Are there any Flutter packages or client-side libraries that support email sending for web applications? Any guidance or code examples would be greatly appreciated. Thank you!


Solution

  • like what @randal and @faBotch said there is no way to send an email from frontend without using backend that is why i used this function:

    void sendEmail(
        {required String email,
        required String subject,
        required String name,
        required String body}) async {
      String encodedSubject = Uri.encodeComponent(subject);
      String encodedBody = Uri.encodeComponent(body);
      String mailtoLink =
          'mailto:$email?subject=$encodedSubject&body=$encodedBody&headers=header1:$name';
    
      if (await canLaunchUrl(Uri.parse(mailtoLink))) {
        await launchUrl(Uri.parse(mailtoLink));
      } else {
        throw 'Could not launch $mailtoLink';
      }
    }
    

    and it is open the Mail application.