postmarker icon indicating copy to clipboard operation
postmarker copied to clipboard

"You have to provide token use Postmark API", with env or variables.

Open mtthidoteu opened this issue 3 years ago • 0 comments

Hi! So I'm trying to send a simple mail for testing purposes, however It is not letting me using any ENV variables or any sort of variable for that matter:

def sendmail():
  postmark = PostmarkClient(server_token=os.getenv('POSTMARK_API_KEY'))
  postmark.emails.send(
    From='[email protected]',
    To='[email protected]',
    Subject='Postmark',
    HtmlBody='Hi',
  )

I am getting the error:

AssertionError: You have to provide token to use Postmark API

If I put it between straight away between ''s it works however. I can also not declare it before such as:

server_token=os.getenv('POSTMARK_API_KEY')
def sendmail():
  postmark = PostmarkClient(server_token=server_token)
  postmark.emails.send(
    From='[email protected]',
    To='[email protected]',
    Subject='Postmark',
    HtmlBody='Hi',
  )

As this returns the same error. Is this the intended behaviour? What could I do as an alternative? Cheers

mtthidoteu avatar Jan 10 '22 13:01 mtthidoteu