如何使用Mailgun发送邮件

时间:2018-08-07 07:39:00

标签: python-3.x angular6 mailgun django-mailgun

现在,我正在使用Django restframework开发angular 6 我的疑问是 用户输入电子邮件ID后,将使用简单的订阅表单,该电子邮件应自动发送

HTML

 <form  #subForm="ngForm" (ngSubmit)="onclick(subForm)" autocomplete="off">
<label>Subscribe</label>
          <div class="input-group input-group-md">
            <input type="text" class="form-control" style="width:66%" #email ngModel name="email" id="email" #email="ngModel"  placeholder="Email Address">
            <button class="btn bth-primary  ncr" type="submit"  >Subscribe</button>
          </div>
         </form>

component.ts

import { Component } from '@angular/core';
import {UsersService} from './users.service';

@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css']
})
export class AppComponent {
  mail= {
    email: '',

  }

  constructor(private userservice: UsersService) {}

  addUser() {
    this.userservice.addNew(this.mail);
  }
}

服务

addNew(): Observable<any> {
        return this.http.get("http://127.0.0.1:7000/information/").pipe(
          map(response => response));

      }

我怀疑在哪里可以使用此mailgun代码,以及哪个更容易使用node.js或Python

var mailgun = require("mailgun-js");
var api_key = 'YOUR_API_KEY';
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: DOMAIN});

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'bar@example.com, YOU@YOUR_DOMAIN_NAME',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomness!'
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

0 个答案:

没有答案