无法使用nodemailer发送电子邮件

时间:2018-10-20 22:05:03

标签: javascript node.js reactjs nodemailer

我正在使用react作为项目的前端,并且在发送电子邮件时遇到问题。我们有一封电子邮件的基本输入行和一个在您输入电子邮件后单击的按钮。然后,此按钮运行onclick函数,该函数使用nodemailer发送电子邮件。我使用module.export能够导入功能sendPasswordChange。但是,当我单击该按钮发送电子邮件时,它总是失败。

import React, { Component } from 'react';
import {sendPasswordChange} from './changepwd.js';
class ForgotPassword extends Component {
    constructor(props) {
      super(props);
      this.handleClick = this.handleClick.bind(this);
    }

    handleClick(){
      var userEmail = document.getElementById('email').value;
      sendPasswordChange(userEmail);
    }
    render() {
        return(
            <div className="form-group">
                <p>Enter your account email to reset your password.</p>
                <input
                    className="form-control"
                    name="email"
                    type="email"
                    id="email"
                    placeholder="Email"
                    onChange={this.handleInputChange}
                />
                <button className="btn btn-primary" type="button" onclick={this.handleClick}>Submit</button>
            </div>
        )
    }
}

export default ForgotPassword;

我已经在线阅读了Node不能用于react的信息,因为它是后端,而react是前端。但是我正在从后端调用一个函数,该函数将在用户单击按钮时运行,因此我认为它应该可以工作,但是不起作用。

0 个答案:

没有答案