mailgun 0.1.2 copy "mailgun: ^0.1.2" to clipboard
mailgun: ^0.1.2 copied to clipboard

A Flutter package for sending email using Mailgun API

flutter-mailgun #

Send email through Mailgun API

Getting Started #

  • Add dependency
dependencies:
  mailgun: ^0.1.0
copied to clipboard
  • Initialize mailer instance
import 'package:mailgun/mailgun.dart';


var mailgun = MailgunMailer(domain: "my-mailgun-domain", apiKey: "my-mailgun-api-key");
copied to clipboard
  • Send plain text email
var response = await mailgun.send(
  from: from,
  to: to,
  subject: "Test email",
  text: "Hello World");
copied to clipboard
  • Send HTML email
var response = await mailgun.send(
  from: from,
  to: to,
  subject: "Test email",
  html: "<strong>Hello World</strong>");
copied to clipboard
  • Send email using template and template's variables
var response = await mailgun.send(
  from: from,
  to: to,
  subject: "Test email",
  template: "my-template",
  options: {
    'template_variables': {
      'author': 'John'
    }
  });
copied to clipboard
  • Send email with attachments
var file = new File('photo.jpg');
var response = await mailgun.send(
  from: from,
  to: to,
  subject: "Test email",
  html: "Please check my <strong>attachment</strong>",
  attachments: [file]);
copied to clipboard

Response #

Below are possible statuses of response.status:

  • SendResponseStatus.OK: mail is sent successfully
  • SendResponseStatus.QUEUED: mail is added to queue, for example, mailgun is not delivered mail immediately
  • SendResponseStatus.FAIL: failed to send email

In case of failure, error's message is under response.message

2
likes
30
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.02 - 2025.04.16

A Flutter package for sending email using Mailgun API

Repository (GitHub)

License

MIT (license)

Dependencies

flutter, http, mail

More

Packages that depend on mailgun