How to Parse a incoming email and send the parsed data as POST request to a endpoint on localhost? - servlets

I have an email for my application, and I want to parse the incoming emails coming to the mail and send the parsed data as a POST Request to an endpoint in localhost(i.e..a servlet). I want to send it to a servlet because I have coded the servlet to send a reply mail for that parsed data.
I found that there are some services for parsing incoming emails like mailparser.io,postmark,sendgrid. Will these services work for localhost? or is there any other ways or services for solving this issue.

This question is quite open, but I try to answer it as best as possible:
Yes, this is possible with SendGrid's "Inbound Parse" feature. For this, you need to register the webhook (SendGrid uses the name "Inbound Parse" here) in the SendGrid console and point to your server, which could run locally. In that case you might need to use a tunnel via ngrok.
If this sounds right for you, please refer to this webinar recording (starting at 2:03:00) to dive deeper or fork this sample code repository

Related

How to send an HTTP Post to a URL from a VG-IDMS

Does someone knows a way of sending an HTTP post to a URL from a VG-IDMS program?
We have a mainframe database with a few programs written on it and we have so far successfully created functionality for it to work as a kinda web service provider, responding to HTTP get requests with XML data. That way we've been able to create external (and modernized) apps that requests data from it as if would be a modern server.
Now we'd like to make the opposite. We want certain VG programs to create and send HTTP post requests to an external URL (most likely JSON formatted although not important). The objective is to create some sort of notification so that when certain events happen on the mainframe (say data got updated) a VG program would notify an external web service (or web api) of it.
I've been trying to find documentation all over but failed so far.
EDIT: Replacing the old mainframe is not an option for now

Cannot do POST in IBM BPM to web service

I'm new to IBM BPM and am trying to put together a process that sends a POST request to a RESTful web service using teamworks.HttpClient.
I am able to POST via Chrome's Advanced REST Client, so I know the server and service are accessible from my system.
When I try to do this via teamworks.HttpClient in Process Designer I get HTTP Status 405. I've only ever seen that when I screwed up and specified GET.
I have written Ajax calls in JavaScript to access this service. I have had to specify POST in the Ajax calls.
Is teamworks.HttpClient configured to be a GET or POST by default? If it does GET, how can I tell it to do a POST?
If I understood correctly what you did, your assumption is correct: teamworks.HttpClient fires a HTTP GET by default. As far as I know, there is no way of configuring it to send a POST request.
I would recommend writing your own Java Integration Service with a more capable web client, this will be really handy for the future anyways:
http://www.ibm.com/developerworks/bpm/bpmjournal/1404_boyer/1404_boyer.html
This resource includes writing your own REST Server, but at the bottom there is also a chapter about implementing a REST Client as a Java Integration Service.

Appropriate http status code for confirmation

I'm implementing an API for a several different client programs to connect to, and I want the api to be able to send back an "are you sure you want to do this?" message, such as when trying to delete something via the api. Looking over the list of established http response codes, I don't see one that seems quite appropriate. I could always skip using a code and provide some other manner of communicating the confirmation, but I would really like to use a standardized method if possible.
The api is normally accessed via a client application, currently a JavaScript-powered one, but I've also made it so that it can be effectively used by directly accessing the api via web browser url.
In what regard would the "Yes I'm sure"-message differ from the "Delete entity 42" message? What would keep clients from immediately sending the "Yes I'm sure"-message? Does your API get accessed by machines or humans?
IMHO this should be solved in the user interface, not in the transport layer.

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

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.

Resources