# FlutterFlow

FlutterFlow (opens new window) lets you build apps incredibly fast in your browser. With EmailJS SDK (opens new window), sending emails directly from the FlutterFlow code will be even easier.
Below, we will explain how to use the SDK in the project.

# Custom Action

Create a custom action where the flutter package can be added.

Add the EmailJS SDK (opens new window) to the Pubspec Dependencies. Since SDK uses the http v1 package and FlutterFlow - http v0 due to the old google_fonts package, update the patch version of this package to solve the version conflict of the http package.

Pubspec Dependencies

emailjs: ^4.0.0
google_fonts: ^4.0.5

To pass template parameters, define arguments. The return value also can be added.

Return Value

The data type is Boolean. The function will return true or false in case of success or failure.

Define Arguments

The templateParams argument with JSON data type.

Action Code

Constants can be stored in the App Values or directly filed to the code.

import 'package:emailjs/emailjs.dart' as emailjs;

Future<bool> sendEmail(dynamic templateParams) async {
  try {
    await emailjs.send(
      'YOUR_SERVICE_ID',
      'YOUR_TEMPLATE_ID',
      templateParams,
      const emailjs.Options(
        publicKey: 'YOUR_PUBLIC_KEY',
      ),
    );
    print('SUCCESS!');
    return true;
  } catch (error) {
    if (error is emailjs.EmailJSResponseStatus) {
      print('ERROR... ${error.status}: ${error.text}');
    }
    print(error.toString());
    return false;
  }
}