Closed alireza5969 closed 5 months ago
Hi.
I'm not sure that I understand your question. Every email that you receive has a message ID. For example:
Message-ID: <datawookie/emayili/issues/155@github.com>
You can find the message ID by viewing the source content of a message in your email client.
When I send a message using emayili, does the package provide a message ID?
The message ID is not generated by {emayili}
. The email server adds it to the message header.
Message-ID: <363de820-2fa9-11ef-0000-f16c3e8a78a1@demomailtrap.com>
Regards, Andrew.
Thank you for your response, Andrew.
From what I gather from your explanation, it seems that the process of sending emails and their subsequent replies programmatically isn’t straightforward. Essentially, after sending an email, one would need to get its assigned ID from a different source before using emayili to send a reply to that specific email.
Is there any workarounds?
See my response on Stack Overflow. I could add the ability to specify the message ID in the sent message, which would prevent the email server from assigning one automatically. This would probably facilitate what you are trying to do.
Thank you Andrew. That would be great.
On Fri, Jun 21, 2024, 12:28 Andrew Collier @.***> wrote:
See my response on Stack Overflow. I could add the ability to specify the message ID in the sent message, which would prevent the email server from assigning one automatically. This would probably facilitate what you are trying to do.
— Reply to this email directly, view it on GitHub https://github.com/datawookie/emayili/issues/155#issuecomment-2182322297, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVZ3ZZUSQGEO2ZF4J43AZDZIPTKXAVCNFSM6AAAAABJVLV7ASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBSGMZDEMRZG4 . You are receiving this because you authored the thread.Message ID: @.***>
I have implemented this on the message-id
branch. Please install and test.
remotes::install_github("datawookie/emayili@message-id")
There are two options to set the message ID:
msg <- envelope() %>% id("bar@nod.com")
or
msg <- envelope(id="bar@nod.com")
Obviously you should construct a unique ID. :smile:
Wow, that was fast! 😄 Thank you very much.
I tested it and it worked. I can now specify the message ID before sending the email. However, it didn't exactly do what I had in mind.
When replying to an email, the original message and the reply should ideally be displayed in a threaded conversation. However, it seems that the emails are still appearing separately in your mailbox despite the modifications.
Here is the code I used:
id <- c(letters, 0:9) %>% sample(size = 24, replace = TRUE) %>% paste0(collapse = "") %>% paste0("@mx.google.com")
message_content <- envelope(
to = "Reciever@gmail.com" %>% address(display = "MR. Reciever"),
from = "Sender@gmail.com" %>% address(display = "MR. Sender"),
subject = "email_subject",
importance = "high",
priority = "urgent",
id = id
) %>%
return_path("Sender@gmail.com" %>% address(display = "MR. Sender"))
message_content <- message_content %>%
text("Hello!")
smtp <- gmail(
username = "Sender@gmail.com",
password = "****************"
)
smtp(message_content, verbose = F)
message_content <- envelope(
to = "Reciever@gmail.com" %>% address(display = "MR. Reciever"),
from = "Sender@gmail.com" %>% address(display = "MR. Sender"),
subject = "email_subject - reply",
importance = "high",
priority = "urgent",
) %>%
return_path("Sender@gmail.com" %>% address(display = "MR. Sender")) %>%
inreplyto(id) %>%
references(id)
message_content <- message_content %>%
text("Hello, again!")
smtp <- gmail(
username = "Sender@gmail.com",
password = "****************"
)
smtp(message_content, verbose = F)
@alireza5969 I've written a short post about this that will appear on my blog later today. Does that help?
Thank you, Andrew 🌸 I read your blog post.
While you’ve meticulously covered every aspect of the problem (such as ID, in_reply_to, reference, and return_path), at least based on my experience with both sender and receiver Gmail accounts, I still can't have threaded conversations. But I think the problem is actually solved as you can see a thread in your inbox 🤔
I also talked about your blog post in Stackoverflow.
Hi!
I know that you have provided two functions inreplyto() references() for replying to emails.
And, you mention that users should use the
msgid
argument in order to reply.But, how can one get the message ID from a previously sent email? When I send a message using emayili, does the package provide a message ID?
I've also asked the question on StackOverflow so more people find it.
Thank you