CDO component hangs occasionally - asp-classic

I have a site which uses a lot of email to confirm actions to clients. As the site has grown the number of emails generated from the pages has grown likewise.
Recently we've started to see the site hanging (or at least anyone who was at the point of sending an email) for a minute or two. I'd put it down to network issues but the guys in the office kept raising it so I've investigated. It turns out that whilst email is going fine 95% of the time, now and again an email send seems to hang for a while and this then hangs anyone else who follows sending a mail. It's as if CDO just freezes and blocks anyone in the queue.
I've proven this by writing a database record immediately before the call to CDO.Send and updating an end time field on it one immediately after... the before record is there 99% of the time but now and again the after record has a NULL date/time so the update never gets called.
CDO seems to have no logs.
The code is correct as it works before and after the glitch. Any ideas?
EDIT: Just realized that the error occurs when the email module is used from two different PC's at the same time. We are talking about a module that sends shipping confirmation from our clients. Using a bar-code scanner we scan the order number and the shipping number into the application, and the javascript function redirects to the ASP page with the details to be included in the email in QueryString.
Happy to post the code if one finds it relevant.

Could it be that one of the email addresses is not a real email address, or that one email address is unauthorised for your mail service?
I ask this because I always get errors like this when setting up a site in IIS for the first run. Most often the localhost (mail server) is not allowed to relay for that user or domain. But by routing through a mail server that is already configured and enabled or at least allowed to relay from your web server usually fixes the problem.

Related

SignalR just for checking if user is online or not

I would like to ask, if it is a good idea to use SinglR just for knowing if the current user now online or not?
For example I have an small website with log in system, and some where on the side i would like to show the logged in members.
Is this a good idea to use signalr for that?
And if it the case should I then on each page start the connection with hub? (In this case when user navigates on the pages, will be the ReConnected method called on hub, or OnDisconnected and OnConnected)?
I'm just starting with signalr, so curious what ppl think.
You could use SignalR though there might be better methods to do this. So when a user logs in, logs out or becomes inactive - you would have some sort of message being sent from the client to the server that indicates the change in status. You can store that information in a temporary database and whenever a value in the database changes you can use SignalR to relay that information to all the connected clients.
Signalr will get reconnected when the user moves from one page to another page. Whenever a user logs into a website the user security details will be persisted in a cookie assuming you are using Cookiebase authentication. So till the user logs out or session timesout the cookie will be active. So there is no real need for Signalr here.
I have been investigating the same thing. From my research, I would say that you COULD do this, but I'm on the fence of whether it's the best way to go about it. I would expect a LOT of disconnecting, connecting and reconnecting. If you're persisting this data in a database, you should anticipate a lot of database traffic. if you're only on a single server though, you could just persist this in memory.
Something to also note is that the ConnectionId changes with each page refresh. At first, I thought that was dumb because I wanted the connection id to be consistent so i could keep a handle on a user with it. However, if you open a link in a new tab and then close one of them, you have to still keep the other connection in storage. If the id was the same you would remove it on disconnect even though the other tab was open, so your user would incorrectly be marked as offline.
However, the other issue that i'm thinking about is that if you're just browsing around the site in a single tab, you will disconnect for a split second between each page load. So you might run into connection consistency issues with that.
I'd say online presence with signalr is more common to be used for a chat room or game lobby. So I'd say this is possible, but whether it's a good solution -- i'm unsure.

ASP.NET SMTP Failover solutions

My knowledge and experience of this is limited, so not sure if I've considered everything and would appreciate some advice.
Current scenario: one Exchange server, one database server, multiple load balanced webservers, all sending confirmation and alert emails on a regular basis. This exchange server is used extensively across the business which is causing a high load which the exchange server can't handle. At one point the server went down for an extended length of time, leading to emails not reaching their destination and with no logging of email attempts to determine what emails failed, so that they can be manually sent at a later date. Additionally, the website waits for the SMTP response so there's a delay in the web page loading.
Plan: A second SMTP server is to be introduced to reduce the load on the original server, along with implementing some improvements to the website to reduce it's resource hogging and improve logging of all email attempts (just header info), with SMTP response status.
Possible Solutions:
Change the website's email method to log, then attempt SMTP via one or other server, record the smtp response. Pros: Quicker to develop, Cons: No asynchronous processing of email queue.
Log email headers, then use MSMQ or RabbitMQ to send email request to a queue, and have a listener service that handles the process of actually sending the email to the Exchange server. Additionally if it continues to fail to reach the SMTP servers, leave it in the queue and retry again at a later time. Pros: Can re-use the infrastructure and experience to use MQ in future feature requirements like user requests to download data, a la Facebook. Cons: Time to learn how to do it, and actually develop when faced with a deadline.
Log email to db, then send to a local pickup folder which relays to the Exchange server, but I think this has no failover support, or method for updating the status in the email log, so while it seems quick to set up, doesn't really meet all of the requirements as far as I can see.
What I'm tempted to do is do is develop in two phases, initially just the first solution then develop the MSMQ/RabbitMQ functionality to make it asynchronous at a later date, but thought I'd ask for opinions to see if I'm overlooking something.
You may want to have a look at NServiceBus.
Specifically, there's some very new email functionality. A satellite has been created that gives you the benefits of the retries that come with NServiceBus to make your email sending more robust.
You get a separate queue without requiring a new endpoint or configuring any message mappings. This way every endpoint has this capability built in and the only config needed is a SmtpClient config section.
The API for this feature is Bus.SendEmail(new MailMessage). They’re using the System.Net.Mail.MailMessage as the abstraction for sending emails.
The code is currently in their develop branch. A sample demonstrating all this can be found here.
For more details see here

E-mail sending using Gmail

I've developed an email application which can be consist of several attachment.size of those attachments could be 20MB or even higher and i'm using smtp.gmail.com as my host.my issue is it's very slow.i think it may because attachments are uploaded when the Send() mail function is called.is there any option to solve this issue?
The bottleneck is your Internet connection upload speed.
The only way to resolve this issue is to lease a faster Internet connection.
On most broadband connections, you should expect this upload to take at least 100 seconds (200k per second upload).
Web Email Clients (Like Gmail) get around this with asynchronous uploaders. The attachment begins uploading as soon as you select it (even while you are still typing out the rest of your email, before you hit send). Unfortunately, I do not believe there is an API that allows async file upload to GMail for this purpose.
With that said, you may be able to do an async upload to another server, and simply link to that file in the emails that you are sending.

Sending mass email campaign via ASP.NET

I have read a few other posts on here about mass emailing, but I need some other information. We want to integrate our mass e-mail system into our current application, but I fear this may not be a good idea. Does anyone have any input as to what kind of resources are needed to send, potentially, 1000's of emails an hour? We only have one web server right now and do not have access to our mail server. We do have full access to our web server, however. Would it be a bad idea to host the mass e-mail application on our current server? Should we have a separate sever to run this type of application and call the server via web services (WCF)? Each email would need to be sent separately because the links on the e-mail are for tracking and unsubscribing purposes. I appreciate your thoughts.
Daniel
Yes its a bad idea,
One of the key things for detecting spam, is the IP address it came from (Known as its reputation) if you start sending out alot of emails which end up getting marked as spam (Which is likly, even if the users said they wated to recieve email) your IP address could end up in trouble. I wouldnt fancy doing this on my webserver.
As for specs, your bandwidth is going to be hit hard when you start doing somthing like this. Although I think you would be suprised at how fast you can send out emails (Mail Server Dependant)
Either way when it comes to sending mass mail campaigns out, I'd speak to a third party if its somthing you are serious about, they have the knowledge and hardware to perform campaigns that are not going to damage your IP rep.
I think this issue all depends on your mail server. I've been in a project where we sent out 50-100K emails in a few hours and the main limitation was the capacity of the mail server. In my opinion it would be fine to have the mail client run on the web server as it won't be using too much resources if well written, the main question is what the mail server can take.
You can help your reputation on some email providers by contacting them and or filling out bulk mail registrations.
This is for yahoo:
http://help.yahoo.com/l/us/yahoo/mail/postmaster/bulkv2.html
I would not recommend using exchange for anything like this. You will want a separate bulk mail server like Ironport.
http://www.ironport.com/
Otherwise your internal emails will get stuck in the queue with all of your bulk emails which you definitely don't want.
The actual code involved does not have to be that complex. In my case we used an asynchronous task to loop over an email list table in the DB pulling out a batch of 20 or so at a time sending then sleeping for a number of seconds. Email providers do not like receiving hundreds/thousands of emails from a source at one time. Even better if you can stagger the list by providers.

Is there any mail queue system in ASP.NET?

Is there any mail queue concept in ASP.NET?
I want to send thousands of different mail to thousands of users (i.e. each user will have a different mail). I want to send the mail at a particular time, so each user receives it at a constant time.
There really is not mail queue in the Core framework. You can send individual messages synchronously or asynchronously, but you can't really send a bunch at once.
You can queue your messages by storing them to a database or file server and then kicking off a job to loop through your saved messages and send them off.
Also, not all of your users will receive the messages at the same time, even if you could send them at the same time. There are too many external variables and dependencies (network traffic, mail server loads, spam filters) to accurately predicate when or even if your users receive their messages.
There's no native MailQueue concept within .NET framework. The queue will have to be implemented yourself. In your case, you would like the mails for each recipients to be sent at about the same time for all batches. Am I right?
Well, this is a bit tricky. You can use any SMTP server, localhost or external ones. But that also mean although you can dispatch to the SMTP server at a specific time, there's no guarantee it will reach the recipients immediately.
There are a whole bunch of stuff on mail delivery which are not exactly programming related (grey listing, spam filtering etc etc).
The alternative is to have full control on the sending and have your app directly sending the mails to the recipients' mail servers. Well that is workable and I suggest you use a commercial or a good open source component for that. Anyhow, there's still a whole bunch of issues you need to deal with, (e.g. some receiving mail server like Yahoo might block the sending a few times and let it through after a few retries).
I've posted a related question, take a look at the replies here.

Resources