-
-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Reset message date on release #194
Comments
Hi. This already exists in the API. See the embedded API documentation (depending on your Mailpit server's URL) on http://localhost:8025/api/v1/#post-/api/v1/message/-ID-/release The request must be a {
"to": [
"user1@example.com",
"user2@example.com"
]
} Obviously you must have relaying configured/enabled for this to work. You would probably first require a call to Hope this helps ;-) |
Oh, nice! I thought it was not implemented as it's not in the API doc but I did not think of checking the actual code, sorry! Would it be possible to add an option/mode to release the message for the recipients (To, Cc, Bcc) specified in the original message? Also, I assume from your example that the post data can contain "cc" and "bcc" keys, or do they all need to be in "to"? |
The requirement to specify all addresses manually was intentional to protect users from accidental spam / mail bombs, so I don't plan on this without good cause. You can easily get the full list of the original recipients as I pointed out earlier. All addresses (that you wish to relay to) go in the Most people don't realise this, but an SMTP server does not scan the message headers to find out who it should go to, it is actually told who it goes to by the SMTP client (or relating SMTP server), so they are not actually linked. |
Thanks for the clear explanation! One final ask: I can see that the original date/time of the message is kept when releasing it. Any chance the date/time could be rewritten to the actual release date/time? |
This could probably be added, I'd need to first consider what the implications of that are. Can you please explain how you are using this to give me a better idea of why this is necessary? |
I have an internal ERP that sends emails for invoices, HR stuff and quotes but I'd like all the emails sent from the ERP to be released at midnight. I wanted to use a solution that provided a UI like Mailpit so that certain emails could be viewed before actually being sent out and to have the ability to remove some if they are not correct. The idea was to use Mailpit as the configured mail target for the ERP and then have a script executed by a CRON job at midnight that would release all available messages. The messages would need to have the actual send time in their headers so that the feeling of an "automated" sending of emails is maintained. I would do all of this in the ERP, but it does not include these features. |
Thanks for the information, makes sense to me. Interesting use case though.... Just for the record, in order to update the I'll keep you posted on this. |
Thanks a lot for considering this! Should I close this issue and open a new one or is it not necessary? |
Please leave this one open, no need for a new one 👍 |
When releasing a message the date header is now updated with the current date & time.
Just to keep you in the loop. I have done some experimenting and this appears to work as expected, and releasing the message to a Gmail-hosted email domain didn't trigger any alarms either (in my opinion Gmail has one of the best spam filtering systems). It's always difficult to tell though as spam filters are dependent now on so many factors. The emails arrive with the "current" date displaying (ie; the new one in the There is something you must always consider before implementing this (given your use case): is the configured relay SMTP server authorised to send email on behalf of your domain (ie: those being generated in via your ERP)? I suspect it will be following a similar path to what previous emails were using (when sent directly), but it's worth remembering if you are now routing the relayed mails via a new SMTP server. This has caught me out several times in the past, as I artificially inject my entire mail database into Mailpit for testing, and releasing something that (for instance) originally came from a @gmail.com address gets rejected as my SMTP IP is not authorised to send those :) Another thing to note is that the original Message ID is always overwritten when relaying - so if somebody replied to a message then your end may not be able to group/thread that reply correctly. This is not a new feature in Mailpit, as email systems like Gmail ignore "duplicate" messages when a message with the same ID already exists. This was implemented to prevent any confusion as to why messages maybe weren't being received (or why just the first release worked but any subsequent one didn't). I still have a bit more testing to do, but I expect this to be released in the next few days. |
Thank you so much for your tests and for taking this into account! I have one more piece of info that could be useful. I don't have extensive data on this yet (I only implemented the solution yesterday, using the current version and waiting to see what would happen at midnight): 3 emails were waiting in Mailpit and my Python script calling the API was successfully executed at midnight. During my tests yesterday, I was releasing emails sent only minutes prior and the time showed in Gmail (for my tests I was doing: ERP -> Mailpit -> Brevo (Sendinblue) -> Gmail) was the original one and not the time when the email was released, which prompted my request here. However, the real emails queued yesterday (1 around 2PM and 2 around 6PM) and released at midnight were showing "00:00" as their received time in Gmail, contrasting with what I was experiencing earlier 🤔 My assumption is that maybe there is a limit allowed for bounces and retries and passing that limit, the actual sending date is displayed rather that the creation date of the message (at least in Gmail, I haven't tested other clients)? IMO this does not render the request made here useless, it's just something to be considered. And again, I have only one execution of historical data, so mileage may vary! |
Thanks for the feedback. I'm not sure exactly how the inner workings of Gmail work, and what/how they base their received dates, but I'm pretty sure the latest change (I referred to earlier) will ensure it's more consistent - at least I hope that's the case. Time will tell (no pun intended) :) Glad to hear your API execution is working as expected too. |
@Leobaillard I have just released this feature in v.1.9.9. Please let me know how you get on? Thanks :-) |
Awesome! Thank you very much, I will update my Mailpit right now and get back to you when it runs! |
Works great, I can see the updated date aligned with the delivery date. Thanks again! I'll close the issue. |
Hi!
I'm migrating from Mailhog to Mailpit and I have a usecase where I'd need to store the emails in Mailpit until a specific time where I would need to release them (all at once or one by one with a loop, it does not matter). This behaviour would need to be automated through a CRON job and thus would not work with the UI which is why an API endpoint would be ideal.
Could such API endpoint be implemented? For instance at the message level like
/api/v1/message/<ID>/release
?Thanks!
The text was updated successfully, but these errors were encountered: