peppermint icon indicating copy to clipboard operation
peppermint copied to clipboard

Problem with sending Mails

Open nimeyer22 opened this issue 2 years ago • 4 comments

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: ([email protected]) 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: ([email protected]) 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 ([email protected]). How do you change this?

nimeyer22 avatar Dec 10 '23 18:12 nimeyer22

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

potts99 avatar Dec 10 '23 21:12 potts99

@nimeyer22 was this resolved for you?

Sending email to:  [email protected]
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.

ravencore17 avatar Dec 30 '23 03:12 ravencore17

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

...

seanpmassey avatar Jan 02 '24 16:01 seanpmassey

This is now resolved @nimeyer22

potts99 avatar Feb 29 '24 13:02 potts99