Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nodeEmailer-发送但不接收电子邮件_Email_Nodemailer_Feathersjs - Fatal编程技术网

nodeEmailer-发送但不接收电子邮件

nodeEmailer-发送但不接收电子邮件,email,nodemailer,feathersjs,Email,Nodemailer,Feathersjs,我正在用feathersjs构建一个API,我需要发送一封带有附件的电子邮件 电子邮件似乎已发送,但我什么也没有收到 在my mail.service.js中 const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport({ host: 'smtp.office365.com', port: 587, secure: false, // secure:true for

我正在用feathersjs构建一个API,我需要发送一封带有附件的电子邮件

电子邮件似乎已发送,但我什么也没有收到

在my mail.service.js中

const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
  host: 'smtp.office365.com',
  port: 587,
  secure: false, // secure:true for port 465, secure:false for port 587
  auth: {
    user: 'gil.felot@myaccount.com',
    pass: 'MyPassWord'
  }
});

// Check the connection to the service.
transporter.verify(function(error, success) {
  if (error) {
    console.log(error);
  } else {
    console.log('Server is ready to take our messages');
  }
});
然后在我的钩子里

hook => {
    const file = hook.params.file;

    const email = {
      from: 'gil.felot@myaccount.com', // sender address
      to: 'mygmailaccount@gmail.com', // list of receivers
      subject: 'Test Nodemailer', // Subject line
      // text: req.body.text, // plaintext body
      html: '<b>Hello world Ok I figure it out !

I needed to add the
transporter.sendMail()
inside the
mail.class.js
to trigger this action when I call
hook.app.service('mail').create(email)

Working and the attachement file that is 0 byte in the mail but the good size inside my variable.

I was missing the from part while creating a mail while I was able to send mail via google smtp but my own smtp was failing with the above configuration

Was working with google

var mailOptions = { to: email, subject: 'Forgot Password', html: mailData };
hook=>{
const file=hook.params.file;
常量电子邮件={
来自:吉尔。felot@myaccount.com“,//发件人地址
致:'mygmailaccount@gmail.com“,//接收者列表
主题:'测试节点邮箱',//主题行
//text:req.body.text,//纯文本正文
html:“你好,世界好的,我知道了

我需要在
mail.class.js
中添加
transporter.sendMail()
,以便在调用
hook.app.service('mail').create(email)


正在工作,邮件中的附加文件为0字节,但变量中的大小很好。

创建邮件时,我丢失了from部分,虽然我可以通过google smtp发送邮件,但我自己的smtp在上述配置中失败

他在和谷歌合作

var mailOptions = { from: 'serverName.com', to: email, subject: 'Forgot Password', html: mailData };
同时使用我的smtp:

let transporter = nodemailer.createTransport({
name: 'example.com' // <= Add this
host: 'smtp.example.email',
port: 587,
在定义
nodemailer
配置时,请考虑添加名称

let transporter=nodeEmailer.createTransport({

name:'example.com'//有时需要花费一些时间。非常感谢!在smtp连接uri append的情况下,nodeEmailer配置中缺少
name
key是我的问题