emailjs 1.2.1 copy "emailjs: ^1.2.1" to clipboard
emailjs: ^1.2.1 copied to clipboard

EmailJS helps sending emails directly from the Flutter app. No server is required.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:emailjs/emailjs.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo EmailJS',
      theme: ThemeData(
        primarySwatch: Colors.orange,
      ),
      home: const HomePage(title: 'Flutter Demo EmailJS'),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key, required this.title});
  final String title;

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  void _sendEmail() async {
    try {
      await EmailJS.send(
        '<YOUR_SERVICE_ID>',
        '<YOUR_TEMPLATE_ID>',
        {
          'user_email': 'hi@example.com',
          'message': 'Hi',
        },
        const Options(
          publicKey: '<YOUR_PUBLIC_KEY>',
          privateKey: '<YOUR_PRIVATE_KEY>',
        ),
      );
      print('SUCCESS!');
    } catch (error) {
      if (error is EmailJSResponseStatus) {
        print('ERROR... ${error.status}: ${error.text}');
      }
      print(error.toString());
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Press "Send Email" to send email',
            ),
            ElevatedButton(
              onPressed: _sendEmail,
              child: const Text('Send Email'),
            ),
          ],
        ),
      ),
    );
  }
}
40
likes
0
pub points
89%
popularity

Publisher

verified publisheremailjs.com

EmailJS helps sending emails directly from the Flutter app. No server is required.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on emailjs