jasp402 / Easy-YOPmail

📮 YOPmail emails manager from an NPM NodeJS library
https://jasp402.github.io/Easy-YOPmail/starter-topic.html
18 stars 3 forks source link

Email Should Be Lowercased When Getting Emails/Messages #19

Closed StephenMP closed 2 months ago

StephenMP commented 4 months ago

When attempting to get an email via

const message = await easyYop.readMessage("SomeEmailAddress1234@mail34.fr", id, { format: "HTML" });

I am presented with the error

readMessage(): Error read message
 - readMessage(): The message has been deleted or does not exist. Try reviewing the ID

However, the email and message does exist. When I call:

const inboxResponse = await easyYop.getInbox("SomeEmailAddress1234@mail34.fr");

I receive the expected messages:

[{
  id: "e_ZwDjAwR3ZGpkAGHlZQNjAmR4BGVjAj==",
  from: "...",
  subject: "...",
  timestamp: "17:15",
  page: 1,
}]

When troubleshooting, I noticed that when I looked up the messages on YOPMail, they show the email address with all lowercase letters. So changing my initial request to

// Notice I changed it to all lowercase
const message = await easyYop.readMessage("someemailaddress1234@mail34.fr", id, { format: "HTML" });

I get the email message successfully.

Thus, it's likely that when attempting to get messages, the email address should be converted to lowercase prior to querying YOPMail.

jasp402 commented 4 months ago

Good observation, I'll be checking it out. 👍🏻

StephenMP commented 4 months ago

It would be good to note also that it doesn't always fail to retrieve messages. Sometimes when the casing isn't all lowercase, it will still get the message, but not all the time; however, when I lowercase the email address I always get the message.

jasp402 commented 2 months ago

I have carefully reviewed this case. The page asks you to use a custom email. You can write it, CamelCase or directly all in CAPS. However, when we go to the inbox, it is shown all in lowercase.

image image

The EasyYOPmail API does the same. All the text it receives is converted to lowercase.

const easyYopmail = require('easy-yopmail');

const AUTOMATION_EMAIL = 'SomeEmailAddress1234';

easyYopmail.getInbox(AUTOMATION_EMAIL).then(emails => {
    console.log(emails);
});

image

It seems to me that the error you have experienced may be due to another cause.