Coder Social home page Coder Social logo

smtpmail-drogon's Introduction

SMTPMail-drogon

Simple Mail for the Drogon framework.

It is made as a plugin for the drogon framework. It can be included into the drogon build with little modification of the class declaration.

Update [23-12-2020] Add DNS support

Added DNS support.

Appreciations

  • The implementation takes SMTPClient for Qt from kelvins as reference.
  • There requires a delay SSL encryption from the Tcp-socket (named TcpClient in trantor/drogon) and the major author of drogon reponsed quickly.

Usage

Download to the plugin directory of the target drogon app, E.g. ~/drogon-app/plugins

$ git clone https://github.com/ihmc3jn09hk/SMTPMail-drogon.git
$ cp SMTPMail-drogon/SMTPMail.* ~/drogon-app/plugins
  • Be aware of add the plugin into the config.json. Set the "name" field to "SMTPMail"

Add the reference header and get the plugin from the app(), E.g.

...
#include "../plugins/SMTPMail.h"
...

//Inside some function, E.g. A controller function.
...
//Send an email
auto *smtpmailPtr = app().getPlugin<SMTPMail>();
auto id = smtpmailPtr->sendEmail(
          "127.0.0.1",                  //The server IP/DNS
          587,                          //The port
          "[email protected]",       //Who send the email
          "[email protected]",    //Send to whom
          "Testing SMTPMail Function",  //Email Subject/Title
          "Hello from drogon plugin",   //Content
          "[email protected]",       //Login user
          "123456"                      //User password
          );
...
//Or get noted when email is sent
...
void callback(const std::string &msg)
{ 
  LOG_INFO << msg; /*Output e.g. "EMail sent. ID : 96ESERVDDFH17588ECF0C7B00326E3"*/
  /*Do whatever you like*/
}
...
auto *smtpmailPtr = app().getPlugin<SMTPMail>();
auto id = smtpmailPtr->sendEmail(
          "127.0.0.1",                  //The server IP/DNS
          587,                          //The port
          "[email protected]",       //Who send the email
          "[email protected]",    //Send to whom
          "Testing SMTPMail Function",  //Email Subject/Title
          "Hello from drogon plugin",   //Content
          "[email protected]",       //Login user
          "123456",                     //User password
          callback                      //Callback
          );
$ cd ~/drogon-app/build
$ make

Licence

  • Feel free to use, thanks to open-source.
  • For the sake of concern on commercial usage, a simple licence is included in each of the files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.