Peppermint-Lab / peppermint

An open source issue management & help desk solution. A zendesk & jira alternative
https://peppermint.sh
Other
2.05k stars 223 forks source link

Problem with sending Mails #207

Closed nimeyer22 closed 7 months ago

nimeyer22 commented 11 months ago

Hello,

While trying to send out mails, I got the following message on the console:

2023/12/10 07:54PM 30 pid=23 hostname=d1ae1550a146 reqId=req-1i res={"statusCode":200} responseTime=10.121704936027527 msg=request completed
Error: Mail command failed: 550 5.7.0 Die verwendete Absenderadresse im Mail From: (noreply@peppermint.sh) gehoert nicht zu Ihrem authentifizierten STRATO Paket. - B-UADOM
    at SMTPConnection._formatError (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:790:19)
    at SMTPConnection._actionMAIL (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:1594:34)
    at SMTPConnection.<anonymous> (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:1063:18)
    at SMTPConnection._processResponse (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:969:20)
    at SMTPConnection._onData (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:755:14)
    at SMTPConnection._onSocketData (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:193:44)
    at TLSSocket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:545:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
    at Readable.push (node:internal/streams/readable:375:5) {
  code: 'EENVELOPE',
  response: '550 5.7.0 Die verwendete Absenderadresse im Mail From: (noreply@peppermint.sh) gehoert nicht zu Ihrem authentifizierten STRATO Paket. - B-UADOM',
  responseCode: 550,
  command: 'MAIL FROM'

The problem is that I can't change the "MAIL FROM" and my mail server doesn't allow this (noreply@peppermint.sh). How do you change this?

potts99 commented 11 months ago

ah shit, i'll add a text field for you

ravencore17 commented 10 months ago

@nimeyer22 was this resolved for you?

Sending email to:  xxxx.xxxx@gmail.com
Error: Mail command failed: 550 5.7.0 From address is not one of your addresses
    at SMTPConnection._formatError (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:790:19)
    at SMTPConnection._actionMAIL (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:1594:34)
    at SMTPConnection.<anonymous> (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:1063:18)
    at SMTPConnection._processResponse (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:969:20)
    at SMTPConnection._onData (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:755:14)
    at SMTPConnection._onSocketData (/apps/api/node_modules/nodemailer/lib/smtp-connection/index.js:193:44)
    at TLSSocket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:545:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
    at Readable.push (node:internal/streams/readable:375:5) {
  code: 'EENVELOPE',
  response: '550 5.7.0 From address is not one of your addresses',
  responseCode: 550,
  command: 'MAIL FROM

I'm getting an error when trying to send email notifications. I know these settings work because another application, (ghost CMS), that uses transactional emails are able to send them.

seanpmassey commented 10 months ago

Reading through the nodemailer code for outgoing emails, it looks like the From address is hard-coded into the email templates.

We are setting a reply-to address in the SMTP settings, and it is included in the model for the email type. But it doesn't look like the code is retrieving and using this. I don't have any NodeJS experience, but I think the code would look something like this (using the Assigned Ticket email as an example):

export async function sendAssignedEmail(email: any) { try { let mail;

const emails = await prisma.email.findMany();

if (emails.length > 0) {
  if (process.env.ENVIRONMENT === "development") {
    let testAccount = await nodeMailer.createTestAccount();
    mail = nodeMailer.createTransport({
      port: 1025,
      secure: false, // true for 465, false for other ports
      auth: {
        user: testAccount.user, // generated ethereal user
        pass: testAccount.pass, // generated ethereal password
      },
    });
  } else {
    const email = emails[0];
    const replyto = email.reply
    mail = nodeMailer.createTransport({
      // @ts-ignore
      host: email.host,
      port: email.port,
      secure: email.secure, // true for 465, false for other ports
      auth: {
        user: email.user, // generated ethereal user
        pass: email.pass, // generated ethereal password
      },
    });
  }

  console.log("Sending email to: ", email);

  await mail
    .sendMail({
      from: replyto, // sender address
      to: email, // list of receivers

...

potts99 commented 8 months ago

This is now resolved @nimeyer22