postal icon indicating copy to clipboard operation
postal copied to clipboard

Can't get past error 'The From address is not authorised to send mail from this server'

Open timraybould opened this issue 7 years ago • 4 comments

I'm using the send/raw API and continue to get the same error: The From address is not authorised to send mail from this server.

In the Postal UI, my settings are Yes - you can use the Sender API and therefore Send as Any elsewhere in settings is listed as Enabled.

Details of my API request:

{
    method: 'POST',
    uri: 'https://mail.mydomain.com/api/v1/send/raw',
    headers: {'X-Server-API-Key' : 'MYAPIKEY', 'Sender' : '[email protected]'},
      body: {
        mail_from: '[email protected]',
        rcpt_to: [[email protected]],
        data: req.body.message
      },
      json: true
}

req.body in this case is the raw message payload listed here in the docs, which I'm dumping into my database and see that req.body.message is a long string and req.body.base64 is true.

Side note: the documentation on that HTTP Payloads page is missing rcpt_to and mail_from fields which are included in the raw message payload.

In that mail_from field in the POST request, I've tried hard coding an address at the domain verified in postal like shown above (I can send mail fine from the UI and via SMTP endpoints), and also tried using the address from req.body.mail_from. I've also tried similar combinations in the "Sender" header, including not passing that header at all.

timraybould avatar Apr 26 '19 14:04 timraybould

More info: send/message works fine. Comparing an even more pared down example:

This works:

{
  method: 'POST',
  uri: 'https://mail.mydomain.com/api/v1/send/message',
  headers: {'X-Server-API-Key' : 'xxx'},
  body: {
    from: '[email protected]',
    to: ["[email protected]"],
    subject: "test subject",
    plain_body: "does this work?"
  },
  json: true
}

But this does not

{
  method: 'POST',
  uri: 'https://mail.mydomain.com/api/v1/send/raw',
  headers: {'X-Server-API-Key' : 'xxx'},
  body: {
    mail_from: '[email protected]',
    rcpt_to: ["[email protected]"],
    data: 'the base64 encoded string from the output of the raw message payload'
  },
  json: true
}

I'm thinking it has to be something to do with that base64 encoded string and that the "from address not authorised" error is a misnomer. Should I not be using the base 64 string straight from the raw message payload on the receiving end?

timraybould avatar Apr 26 '19 15:04 timraybould

  • Did you add "mydomain.com" as domain under your organization?
  • If you are using a valid domain.. is this validated?
  • if not.. then try using "development" mode.

All point that your are trying to use an API with no domain where validate your "mail_from: '[email protected]'" user .. so that may not work.

-rbustos

rbustos avatar Apr 27 '19 04:04 rbustos

Given that send/message works, I'd say you have the correct email domain and credential combination however send/raw expects a full message with headers so have you included the correct From header in the base64 encoded string?

Side note: the documentation on that HTTP Payloads page is missing rcpt_to and mail_from fields which are included in the raw message payload.

I think HTTP Payloads are a different thing for messages Postal has received rather than messages you want Postal to send.

willpower232 avatar Apr 29 '19 09:04 willpower232

Ah, yeah that's the issue. I was trying to take receipt of an incoming message then forward the raw contents of it to a new address without modification. Makes sense that this can't be done, because the From address in that raw message isn't the same domain as the server, and, I didn't "crack open" the raw incoming message to add a Sender header to it.

Thanks for the insight. Btw, I do think my comment about that documentation issue is correct. It is the incoming message that I'm referring to. You get access to a couple more fields than the docs indicate. Handy ones too!

timraybould avatar May 02 '19 13:05 timraybould