Mailkit unexpected disconnection from server when downloading headers from Yahoo Mail - imap

I am trying to fetch IMAP headers from Yahoo Mail. It works fine when I try to grab the first 100 headers but it disconnects when I try to get the headers of all 32,000+ emails. I get an exception saying that "The IMAP server has unexpectedly disconnected".
I tried using Gmail to grab up to 19,000 headers and it works fine.
Any ideas or is there any limitations? I have included the protocol log here: https://www.dropbox.com/s/6109m1ii113af0c/protocollog.txt?dl=0

Upgrade your MailKit. The problem is probably that your list of UIDs is too long causing your IMAP server to disconnect.
The latest version of MailKit will break apart the list of UIDs into multiple duplicate commands with smaller subsets of the UIDs in order to avoid creating a command-line that is too long for the IMAP server to handle.

Related

Sendgrid Inbound Webhook - Undelivered notification

As per sendgrid documentation, the way Inbound parser webhook responds to failures are that it will retry to post the email to the configured endpoint for 3 days and will drop the email if undelivered.
The Parse API will POST the parsed email to a URL that you specify. If a POST is unsuccessful, SendGrid automatically queues and retries any POSTs that respond with a 5XX status. This prevents data loss for customers who have misconfigured their website or POST URL.
Respond with a 2xx status to the POST request to stop the email from retrying.
To avoid returning an error your link must return a 2xx HTTP code when the email is received. This response lets our system know that your link has received the email. It is then removed from our send queue. If we do not get a valid 2xx HTTP response, our servers will believe they have failed to deliver your message. Messages that cannot be delivered after 3 days will be dropped.
I would like to know if before dropping the undelivered emails, will sendgrid notify the sender that their email could not be delivered?
Based on a few tests I ran, it does not appear SendGrid will ever send a notification to the sender, nor is there any easy way to ascertain whether SendGrid has dropped any inbound emails.
Although the documentation wording is slightly ambiguous, my understanding based on testing (which aligns with the documentation wording) is this:
Server returns 2xx: email is deemed accepted, no further attempts made.
Server returns 5xx: server has error, attempts made until 2xx is returned (see below for timing of subsequent attempts), or 72 hours lapses
Server returns any other response, or DNS records do not exist: email is deemed failed, no further attempts made.
My conclusions are based on a number of tests I ran over the course of a week, from which I ascertained the following:
Case 1. Parse server returns 400 or 403 error
The email is dropped after one attempt.
No further attempts are made to POST the email.
No notification is sent to the sender or to the SendGrid account.
(Test method: Configure SendGrid to a URL that returns one of the above error codes. Checked server logs over 1 week, and noted only one attempt was made.)
Case 2. The parse hook URL does not have a DNS record
The email is dropped, presumably after one attempt.
No notification is sent to the sender or to the SendGrid account.
(Test method: configure the hook URL to a subdomain that does not have any DNS records. Run DNS search and try opening the hook URL to confirm the DNS records do not point anywhere. Send an email. Then, after 12 hours, add an appropriate record to the subdomain to point it to a script. Checked server logs and confirmed no attempts were made to POST the email. A subsequent email attempt successfully POSTed.)
Case 3. Parse server returns 500 error
SendGrid attempts to POST to the hook URL at the following intervals:
+0 +5m +10m +15m +20m
+25m +35m +50m +1h20m +2h20m
...then every 3 hours
The last attempt occurs +71h20m
The 20 min offset is a bit unusual, but it falls on the hour, so it may be because the message is queued to attempt POSTing on the hour.
No further attempts are made to POST the email after 72 hours.
No notification is sent to the sender or the SendGrid account.
Statistics
The documentation refers to the availability of statistics, however, I have found the numbers to be inaccurate.
For example, during my testing, I had a number of emails go through the API, including some that were intended to be successful (and did indeed POST to my server) and a few that were intended to fail (as part of the above testing), however, the numbers returned did not align.
Takeaways
Care should be exercised in the following scenarios:
Server downtime: this would ultimately depend on how the server is configured. If the server returns a 5xx response code, SendGrid will keep trying to POST the email. I also tried to test a timeout scenario, however, SendGrid seems to be very patient (e.g. I made my script pause for 10 minutes, SendGrid kept the connection for 10 minutes, though interestingly, due to the second attempt occurring after 5 mins, the email POSTed twice).
Server misconfiguration that returns 4xx error codes. SendGrid will drop the email.
It should also be noted if an email is dropped, there doesn't appear to be any reliable method of finding this out.
SendGrid won't send a notification before the email is dropped. However, the message will be dropped only after receiving an error from your Webhook URL and retrying to post the message for three days.
We got a confirmation from the Sendgrid support team, that the emails that are dropped in the Inbound Webhook Parser feature, will not have any notification or being saved in Sendgrid. So, we won't be able to get any info regarding the emails which are dropped.

How to fix 403 error what Twilio calls my webhook?

We're using Twilio. We have webhooks set up so that when Twilio receives a call, it forwards it to a URL on our site.
This appears to have been working fine. But now I made a change to the code, and suddenly Twilio is having problems calling the webhook. We don't receive the message, and if I look in the Twilio log, it says it got a 403 error. (I can't swear that this has never happened before. I've never noticed a message to be lost, but maybe I missed it while debugging other errors, attributed a lost message to something else.)
The truly strange part is, about 2/3 of the message that come in are received and processed fine, but about 1/3 get the 403 error. This is on a test server where we don't have any load balancing, so all requests are going to the same instance of our app. The tests I've been doing today are all from the same cell phone to the same Twilio number.
We do have authorization on the app, but the authorization is all on sub-directories, not the top level, and the sub-directory with our web hook has no authorization set up.
The first thing my our web hook now does when it gets called is send me an email with the content of the message from Twilio. (For debugging purposes.) I'm not getting that email, so I'm very confidant it's not getting called. And as I say, I can look at Twilio's log and it says that it received the text message and got a 403 error trying to forward it to my webhook.
The fact that it's only like 1/3 of the time is particularly puzzling. It's from the same number, to the same number, hitting exactly the same URL on the same site. Why would it work sometimes and not other times?
I tried to reproduce the problem on my desktop by calling the URL directly, not going through Twilio, and that does not give the same error. (It occurs to me as I type that the next logical test is to hit the page on the server without going through Twilio.)
Oh, the server is ASP.NET. The code is in VB but I doubt that matters as we're not getting as far as executing any of our code when it fails. When it doesn't get the 403, the code is working fine.
Check your firewall configuration as it might block the requests.
If it does then whitelist requests originating from Twilio.
We're using AWS WAF and ran into a similar situation: We saw the requests erroring out with a 403 in the Twilio Debugger but the requests never hit our endpoints. Once we adjusted the whitelist the problem was gone.

timeout in telegram.bot webhook - asp.net mvc

I had been developed a telegram bot using Telegram.Bot.
I tried to rework with the bot, First I created bot using BotFather and got token.
I set webhook server api address in telegram api. But when I check webhookinfo it returns this error
https://api.telegram.org/botToken/getWebhookinfo
respone:
"last_error_date":1585419712,"last_error_message":"Connection timed out"
I checked it need TLS12 to have secure connection using
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
But It's not getting updates in my server and show time out error.
I tried posting using postman and ngrok to run on my iisexpress and I'm getting data and can sending messages to bot in my localhost.
But In hosting it's not working, whats wrong with new Telegram.Bot library or telegram server?
update
I checked with postman my hosting url, post man also cant connect to that url. what can be wrong with my codes?
This is response when i'm call update receiving URL in my hosting:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.10.34.35:443
I got problem, the certificate which we use should be valid one, not free.
For more information please study this link:
https://core.telegram.org/bots/webhooks

Indy IMAP remove mail attachment from server

I want to remove attachments (files) from mails on the (exchange) server.
I currently use IMAP to access the accounts and mailboxes.
How do I remove the attachments on the server side without removing the message?
What you are asking for is not possible with IMAP. The only option is to download the desired message in full, alter it as needed, delete the original from the server, and then upload the modified copy.

Put Downloaded Emails Back to POP3 Server

How can I put my downloaded emails back to my POP3 server? I want it to appear like how it was sent originally. I made a mistake of setting thunderbird to delete my server-side emails and keep only the local one. Now I need to re-upload it back to my web mail. How do I go about doing such?
NOTE:
The Mailredirect Extension is not compatible with my current ThunderBird so I don't think that trick will be possible.
The POP3 protocol has no provisions for uploading messages. You could use IMAP to upload them, if the server supports it, or just re-submit the messages to the mailserver via SMTP (this will add more Received: lines, and pass through any spam filtering or the like again, however)

Resources