Sending Email from centralized server with multiple web servers - c#-4.0

I am building a ASP.NET MVC3 application that will be running on a couple web servers. Instead of each server/app sending its own emails(Asnyc) per request, I would like to leverage something like MSMQ and send messages to an email server that would pick up the messages and send an email.
I have an idea of how to do this with a console app, windows service and MSMQ but was looking for some direction from anyone who has had success/experience implementing something similar. Any guidance, experience, technology, blog posts would be appreciated.

From what I see you're simply after an e-mail relay service. You could just use a dedicated IIS to do this for you. IIS SMTP has builtin queued mail relay functionallity. Preferably you want to cluster this IIS SMTP service for max. reliability.
Regarding the consideration in the article linked I can't see the difference between the users page process waiting for sending a message to an SMTP server and sending a message to a MSMQ.
I believe when it come to redundancy you'll find it much easier to set up a clustered SMTP service than clustered MSMQ.

Related

Adding more verbose detail to DocuSign Connect and API logging

We are encountering inconsistent results with DocuSign Connect integration where some envelope transactions are received by the listening server while others are not. This DocuSign integration involves two web servers with load balancing (listening app on both). The existing log details lack enough troubleshooting data to describe reason for the Connect failure events.
DocuSign Connect logs the responses it receives from the customer's Connect servers (or "listeners"). But Connect is merely the client of your servers.
The best logging will be your servers' logs.
Are your servers processing the incoming notifications synchronously or putting the notifications messages onto a queue and then later processing the messages asynchronously? The latter is a more reliable and recommended pattern.
You may want to consider switching to a PaaS solution that incorporates asynchronous queuing:
If you use a PaaS (Platform as a Service) system such as AWS or Azure, the cost of the intermediate system will be zero (AWS) or very low (Azure, etc) for as many as a million messages per month.
In addition, the PaaS pattern will enable your application to receive the notification messages from behind your firewall, with no changes to the firewall.
More information: https://www.docusign.com/blog/dsdev-webhook-listeners-part-4/
Code examples for AWS, Azure, Google Cloud for C# .NET Core, Java, Node.js, PHP, and Python are available from DocuSign’s GitHub repository. See the repository listing via this link. The repos all start with Connect-
After you receive a notification message, your application can use it to trigger a download/storage of the envelope’s documents; to start a new process since the envelope has now been signed, etc.

Problems setting up NodeMailer with MailGun

I'm trying to set up NodeMailer v0.7 in an Azure App Service for my Ghost blog. No matter what I do, I cannot get it to send mail when the exact same configuration is working in another environment.
It keeps telling me Relaying Denied. I've written up an extensive troubleshooting support page on this if anyone would like to help me.
I would GREATLY appreciate any help you can provide.
https://www.notion.so/Azure-Web-App-Ghost-Blog-Email-Issue-ef9221fde09d47e29a211ea45357563e
On Azure App Service, for sending email, the recommended way is to use SendGrid or O365.
Due to some reason for SMTP, I think you can not directly use nodemailer to send mail on Azure WebApp, please see the blog Troubleshooting SMTP issues/Sending emails from Azure Web Apps from a MS Support Engineer to know, and the first Q & A explains your current issue, as below.
1. Are you using a Relay Service or are you trying to send email directly from the web application?
If you are not using a relay service to send email, you are in an
unsupported scenario within all of Azure (including running an
application in a VM or cloud service). To reduce the possibility of
customers using Azure resources to send SPAM emails we do not allow
sending email directly from any service in Azure. See the blog below.
Relay services include SendGrid, O365, other third-party relay
services, and customer’s own on-premises relay services. So first
verify if the customer is using a relay service. If they do not have a
relay service they must configure their application to use one, there
is no other workaround.
https://blogs.msdn.microsoft.com/mast/2017/11/15/enhanced-azure-security-for-sending-emails-november-2017-update/
If you consider to switch to SendGrid, #sendgrid/client can help you to easier send mail.

RabbitMQ security in mobile app

I am using Rabbit MQ broker in one of mobile apps that we are developing, I am bit puzzled about security aspects. we are using cloud hosted rabbitmq and hosting platform has given us user name and password (which have been changed since) and we are using SSLconnection so not so much worried about MIM or eavesdropping.
my concern is anybody who knows host and port can make connection to rabbitmq, since we have mobile app we are storing rabbitmq user name and password on device (although encrypted) so I guess that anybody who gets physical access to device and somehow decrypts username password can login to rabbitmq, and once you are logged in you can pretty much do anything on rabbitmq like deleting queues etc..
How are MQ like Rabbitmq used in mobile environment. Is there a better / more secure way of using rabbitmq.
In my experience, it is best to not have your mobile app connect to rabbitmq directly. Use a web server in between the app and RabbitMQ. Have your mobile app connect to your web server via HTTP based API calls. The web server will connect to RabbitMQ, and you won't have to worry about the mobile app having the connection information in it.
There are several advantages of this, on top of the security problem:
better management of RabbitMQ connections
easier to scale number of mobile users
ability to add more logic and processing to the back-end, as needed, without changing the mobile app
creating a connection to RabbitMQ is an expensive operation. It requires a TCP/IP connection. once that connection is open it stays open until you close it. if you open a connection from your mobile app and leave it open, you are reducing the number of available connections to RabbitMQ. if you open and close the connection quickly, you are inducing a lot of extra cost in creating and closing the connections constantly.
with a web server in the middle, you can open a single connection and have it manage multiple mobile devices. the web server will handle the http requests and use the one connection to rabbitmq to push messages to it.
since an HTTP web request is a short-lived connection, you'll be able to handle more users in a short period of time, than you would with direct rabbitmq connections.
this ultimately leads to better scalability as you can add another web server to handle thousands more mobile app instances, while only adding 1 new RabbitMQ connection.
this also lets you add middle-tier logic inside of the web server. you can add additional layers of processing as needed, without changing the mobile app. change the web server code and redeploy as needed.
if you must do this without a server in the middle, you likely won't be able to get around the security issue that you're having. the mobile device will contain the necessary information to make the connection.

Windows Azure sending email via SMTP relay

I have a site hosted on Windows Azure and currently I am using SendGrid to send emails. However, we have Mimecast as our email provider and it is marking all emails received from SendGrid as spam.
Is there a way to use Mimecast as the SMTP Relay service from my Windows Azure application?
Well,
Azure as such does not apply any restriction on the outgoing traffic (beside some bandwidth throttling based on the Size of the VM you are running on, but this quite generous). So in practice you can use any SMTP relay service.
Whether you can use Mimecast specifically, you shall turn to Mimecast support or products page. But there is nothing in Azure that would stop you from using this or that service (any service).
And Yes, you can use System.Net.Mail.SmtpClient or any other Smtp Client library to talk to external SMTP Service. Whether that external SMTP Service will accept your connection or not, is not subject to any kind of Azure limitation, but sole decision of the service you chose to use.
You should raise a ticket with SendGrid so they can manage this situation. The reason SendGrid is provided is to precisely avoid your mail being marked as spam. You will be unlikely to see any successful mail delivery if you route SMTP traffic directly from an Azure host to a receiving SMTP server.

Right Way to Secure MSMQ over HTTP

We're in the middle of migrating an e-commerce integration from using batching to messaging (MSMQ). The e-commerce application itself is hosted on a web server that is not in our domain. The machine processing orders is in the domain in our LAN. The e-commerce app will write to a local MSMQ when an order is placed. Our order processing component should connect to this queue and read messages from it. We are not using WCF for this.
If it were up to me I'd either ditch MSMQ and go with RabbitMQ or put a vpn client on both machines like Hamachi.
I know that MSMQ can use HTTP as a transport via IIS. However I can't seem to find much documentation on how to set this up securely. Is it as simple as turning on one of the authentication options in IIS? I would prefer to use basic auth as we plan on doing this over HTTPS. After that, how to send credentials from the order processing component?
MSMQ supports HTTP and HTTPS. For details, see http://technet.microsoft.com/en-us/library/cc785272(v=ws.10).aspx
Cheers,
Yoel

Resources