Git Product home page Git Product logo

jmap-samples's People

Contributors

chris-morgan avatar dependabot[bot] avatar gorenje avatar itsthejoker avatar mmcclimon avatar rjbs avatar robn avatar tjwds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmap-samples's Issues

Node samples list no dependencies in package.json but some are in package-lock.json

Hi! I am looking at the JavaScript sample and I believe something unintentional has happened. The package.json file lists no dependencies, but package-lock.json does contain a number of resolved dependencies.

Initially I figured I would send in a PR adding the dependencies in so that when running npm install, the package-lock.json would be what it is today as committed. But I realized the only direct dependency was probably node-fetch? And the fetch API has since become a part of the Node runtime itself since the version 18.

I don't think the Node docs site lists fetch in the API docs yet, at least I couldn't find it… But it is listed on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#browser_compatibility. Here is the Node commit adding the support: nodejs/node@6ec2253

I think as long as you're fine requiring Node 18+ to run the samples, it would be completely sufficient to just remove package-lock.json? No npm install command needs to be run, one can go straight to node hello-world or node top-ten.

Would it be welcome for me to send in a PR where I remove that file?

Sample for EventSource connection to Fastmail?

Hey folks,

I'm working on a JMAP client for Python that uses AsyncIO, following the specs at https://jmap.io/spec-core.html. I've got the JMAP portion of the API functioning, and I can use that to fetch mailboxes and emails from my personal account. However, when trying to connect to the EventSource URL and stream changes, I always get a 401 Unauthorized error, with "Incorrect username or password."

I'm using the same HTTP client/auth parameters that I use for connections to the JMAP API, and the spec does not mention anything about authentication specific to the EventSource API. Is there a different authentication standard necessary for EventSource connections, or is this something that's not supported for third party applications with Fastmail?

Sample for downloading an attachment?

I've been reading through the JMAP specs and the Fastmail docs, and I can't figure out how to use JMAP to fetch an individual attachment from an email.

  • Is this even possible? I can use other methods to get the attachment bytes, but it has all the other metadata (mime-type, name, blob id, etc) so that it feels like it should be right there.
  • If it's possible, can it be added to this repo as an example? (I could make a PR once I understand it.)
  • If it's not possible, is there a related Fastmail API that I could use instead?

Is there a full API list available?

Hi, today is the first time I've even heard of JMAP.

Is there a full list of APIs / endpoints / nodes / whatever it's called in JMAP terminology implemented by fastmail available?
The second part is important, since it seems like FM implements a subset of the JMAP Email spec, e.g. #7 (comment)

Specifically, I'd like to programmatically create labels and rules.

.NET platform example?

I'm curious to know if you could produce a .NET platform example. I'm attempting to do some work with the Fastmail JMAP API myself, but I'm finding that I fail at the authentication step. Everything about my code looks correct from a Basic authentication POV, Base64 encoding, etc, etc. I'm suspecting that if one of your engineers attempted this and had the same issue as myself they may be able to identify what is happening in the backend that is preventing my code from authenticating.

How to submit multiple emails at once when call "EmailSubmission/set"?

I try to submit email A and B at a request.
E1 has only one recipient R1, E2 has only one recipient R2, which are omitted in the request.
But the submission result is unexpected. R1 will receive E1, R2 will receive both E1 and E2.

{ 
    "using":
    [
        "urn:ietf:params:jmap:core",
        "urn:ietf:params:jmap:mail",
        "urn:ietf:params:jmap:submission"
    ],
    "methodCalls":
    [
        [
            "EmailSubmission/set",
            {
                "accountId": "MY_ACCOUNT",
                "create":
                {
                    "0":
                    {
                        "identityId": "MY_IDENTITY",
                        "emailId": "E1"
                    },
                    "1":
                    {
                        "identityId": "MY_IDENTITY",
                        "emailId": "E2"
                    }
                },
                "onSuccessUpdateEmail":
                {
                    "#0":
                    {
                        "mailboxIds/MY_BOX1": true,
                        "mailboxIds/MY_BOX2": null,
                        "keywords/$draft", null

                    },
                    "#1":
                    {
                        "mailboxIds/MY_BOX1": true,
                        "mailboxIds/MY_BOX2": null,
                        "keywords/$draft", null
                    }
                }
            },
            "0"
        ]
    ]
}

Where do Identities appear?

Hi There!

I've managed to create Identities using the JMAP API. As basis, I've used the python3 example in this repo.

What I did was replace the create_res call in the example with the following bit of code:

create_res = client.make_jmap_call(
    {
        "using": [
            "urn:ietf:params:jmap:core",
            "urn:ietf:params:jmap:mail",
            "urn:ietf:params:jmap:submission",
        ],
        "methodCalls": [
           [ "Identity/set", {
               "accountId": account_id,
               "forbiddenFrom": False,
               "create": { "fubar": {
                   'bcc': None,
                   'email': '[email protected]',
                   'htmlSignature': '',
                   'name': 'MyName',
                   'replyTo': None,
                   'textSignature': ''
               }}
           }, "howzats" ],
           [ "Identity/get", {
               "accountId": account_id,
           } , "pluckaduck"]
        ]
    }
)

The identity is actually created and the get request lists the new identity, but now my question: where do I see the new identity in the Fastmail web interface? I've looked in Settings --> Users & Aliases which actually does list the identities that I've created through the web interface but not those created via JMAP API.

302 redirect

Hi,

I'm trying to build a mini test app to connect to fastmail via jmap using c#. I'm having an issue when I try to get a session with a 401 unauthorized. After debugging and profiling a bit, it seems pointing to https://jmap.fastmail.com/.well-known/jmap after authentication is redirecting to /session and I get a 302 redirect response.

I tried to replicate with postman but I can authenticate just fine.

Can anyone seems to identify the issue?

Here's a sample code:

HttpClient _client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
_client.DefaultRequestHeaders.Clear();
_client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Helpers.Base64Encode($"{WellKnownKeys.FASTMAIL_USER}:{WellKnownKeys.FASTMAIL_PASSWORD}"));
var response = await _client.GetAsync(WellKnownKeys.FASTMAIL_JMAP_SERVER);

PS: Pointing directly to /session returns a session without issues.

Thanks

InvalidProperties 'identityId'

Hi There!

I've been playing around with the python3 example here and keep getting the same error when trying to submit the test email:

{'methodResponses': [['Email/set',
                      {'accountId': 'XXXXXXXXX',
                       'created': {'draft': {'blobId': 'Gxxxxx',
                                             'id': 'Mxxxxxx',
                                             'size': 597,
                                             'threadId': 'Txxxx'}},
                       'destroyed': None,
                       'newState': '18705',
                       'notCreated': None,
                       'notDestroyed': None,
                       'notUpdated': None,
                       'oldState': '18703',
                       'updated': None},
                      'a'],
                     ['EmailSubmission/set',
                      {'accountId': 'XXXXXXXX',
                       'created': None,
                       'destroyed': None,
                       'newState': '18542',
                       'notCreated': {'sendIt': {'properties': ['identityId'],
                                                 'type': 'invalidProperties'}},
                       'notDestroyed': None,
                       'notUpdated': None,
                       'oldState': '18542',
                       'updated': None},
                      'b'],
                     ['Email/set',
                      {'accountId': 'XXXXXXX',
                       'created': None,
                       'destroyed': None,
                       'newState': '18705',
                       'notCreated': None,
                       'notDestroyed': None,
                       'notUpdated': None,
                       'oldState': '18705',
                       'updated': None},
                      'b']],
 'sessionState': 'cyrus-17101;p-11'}

I can create the draft but not send it - so the authentication stuff is working ...

Does the example need updating?

Cheers!

What does this error mean `invalidProperties` `emailId`

I have not included an emailId in my code, yet I am returned this error.

EmailSubmissionSetResponse(account_id='u5ba9403a', old_state='33120', new_state='33120', created=None, updated=None, destroyed=None, not_created={'emailToSend': SetError(type='invalidProperties', description=None, already_exists=None, not_found=None, properties=['emailId'])}, not_updated=None, not_destroyed=None)

emailid commented out below.

                # Send the created draft email, and delete from the Drafts mailbox on
                # success
                EmailSubmissionSet(
                    on_success_destroy_email=["#emailToSend"],
                    create=dict(
                        emailToSend=EmailSubmission(
                            # email_id="#draft",
                            identity_id=identity.id,
                            envelope=Envelope(
                                mail_from=Address(email=identity.email),
                                rcpt_to=[Address(email=identity.email)],
                            ),
                        )
                    ),
                ),

Possibility to send emails via `curl`?

Hello -- I am wondering if it is possible to send an email (possibly with attachments) via curl? It would save a lot of time tinkering the given examples.

Mailgun can achieve this via

curl -s --user "api:$MAILGUN_API_KEY" "https://api.mailgun.net/v3/$MAILGUN_DOMAIN/messages"
      -F from="[email protected]"
      -F to="[email protected]"
      -F subject="Subject"
      -F text="`export`"
      -F attachment="@attachment.pdf"

This is extremely useful especially when incorporating email notifications in CI/CD workflows.

How to use results in complex queries

I'm trying to create a set of methodCalls that retrieve some mailboxes, retrieve message ids that match the criteria, and then change the labels for the messages. If I do each step separately, and store the results, it works fine (that is I retrieve the mailbox id through a method call, then retrieve the email ids, then set the labels, each with separate calls to the server). There's obviously something basic I'm missing, and I've read all the docs and the samples (all the samples do simple things like retrieving a list of IDs).

This is the code I have so far, I haven't added changing the labels yet. But even this doesn't work beyond the first method call to retrieve the mailbox ids.

{
  "using": [
    "urn:ietf:params:jmap:core",
    "urn:ietf:params:jmap:mail"
  ],
  "methodCalls": [
        [
      "Mailbox/query",
      {
        "accountId": “xxx”,
        "filter": {
          "role": "inbox"
        }
      },
      "inbox"
    ],
    
    [
      "Mailbox/query",
      {
        "accountId": “xxx”,
        "filter": {
          "role": "archive"
        }
      },
      "archive"
    ],

    [
      "Email/query",
      {
        "accountId": “xxx”,
        "filter": {
          "#inMailbox": {
            "resultOf": "inbox",
            "name": "Mailbox/query",
            "path": "/ids"
          },
          "before": "2023-01-01T01:17:02Z"
        }
      },
      "messages"
    ],
    
    [
      "Email/set",
      {
        "accountId": “xxx”,
        "update": {
          "#ids": {
            "resultOf": "messages",
            "name": "Email/query",
            "path": "/ids"
          }
        }
      },
      "null"
    ]
  ]
}

Example for creating an Email with attachment?

Hi There!

Following up from #18 - howabout an example for adding an attachment?

From RFC specs (which btw are very broad and difficult to understand), to the Jmap.io, to the example code here and finally to the example code from jmap.io, I understand that it's not simply a case of attaching a binary string to the Email/set command and bob's your uncle!

No, as I understand there must be a hidden Blob/set command:

There is a single endpoint that handles all file uploads for an account, regardless of what they are to be used for.

source

Now I would like to know what is that endpoint in the case of Fastmail and what exactly do I send to that endpoint? Or can I send a Blob/set command as part of my Email/set and EmailSubmission/set commands that I send to https://api.fastmail.com/jmap/api endpoint?

Every time I have a look at Jmap, I have the impression that the standard isn't going anywhere - broken examples is just one example. Where are the well explained example code snippets? Please point me to them!

I am continually looking through code examples to find how to do the most basic things with Jmap, something that a thousand SMTP libraries would do in a second.

Why doesn't Fastmail produce a single library that does everything in a simply and straight forward way? Instead we have these samples that cover how to download an email using five different languages ... does not really cut the ice! And that for at least five years - there has been little or no movement in the standard.

This repo does not even have an readme pointing to the specs and perhaps jmap.io and perhaps to better implementation than the ones here. It all seems to be disregarded and unmaintained (viewed from outside).

Sorry for the critical comments, it's the JMap command Frustration/get, from the specs:

The Frustration/get command is triggered after spending an hour fruitlessly trying to understand the JMAP documentation. The return value of this command MUST be shared with the broader world by creating a issue on JMAP-Samples. This SHOULD reduce the size of the return value.

.NET JMAP Library

Hi there - I recently stumbled across JMAP, and as a fan of well-designed APIs and my Fastmail account, I had to take the opportunity to muck around a little bit.

Unfortunately, I couldn't find any .NET libraries for it, so then I had to make one.

Would you be interested in a pull request with a sample?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.