Getting emails via LocalStack / AWS SES - cypress

I am trying to use LocalStack for my end to end tests but I cannot read the emails sent via LocalStack/SES. Is there a way to do that?
I want my Cypress e2e tests to invoke my backend services, the backend services compose an email containing a link and send the email via LocalStack/SES. I then want my e2e tests to wait for that email, read the link sent in it, and proceed.
I managed to invoke LocalStack's SES to send the email, and I am aware that the moto library backing LocalStack stores the sent messages in memory. Is there a way to read those messages?

The sent messages can be retrieved via a service API endpoint (GET
/_localstack/ses) or from the filesystem.
Messages are also saved to the data directory (DATA_DIR, see
Configuration). If data directory is not available, the temporary
directory (TMPDIR) is used. The files are saved as JSON in the ses/
subdirectory and organised by message ID.
Reference:
https://docs.localstack.cloud/aws/ses/

Localstack uses Moto and Moto does expose the ability to check the sent emails. It is discussed here
https://github.com/spulec/moto/issues/1392
Taking a look at the code for localstack doesn’t look like they expose a function to access this information.
https://github.com/localstack/localstack/blob/master/localstack/services/ses/ses_starter.py
You will need to make a pull request to Localstack and add a function which exposes the ses_backend or specifically the sent_messages array.
from moto.ses import ses_backend
ses_backend.sent_messages
I am not using localstack for SES I am running the E2E tests against our real Quality Assurance Testing environment (real SES). In that case you can use one of the following.
What you need is a programmatic way of reading the inbox and checking the emails by title and maybe the body too.
Mailosaur https://mailosaur.com/
The API is simple to use with Java which fit our use case. In addition to that the response from their sales /support. They also have SMS services too which we are not using.
MailSlurp https://www.mailslurp.com/
This was our first choice just because it’s the first one we found and it looked pretty good. But we tried to contact them and never go a reply. They still haven’t replied and we sent half a dozen emails.
MailTrap https://mailtrap.io/
There was a third service which is suitable if your working with JavaScript (please use Typescript) as it’s REST based. But for Java REST APIs end up being quite verbose with the code which I am not a fan of. But if you are in JavaScript this option is suitable.
The prices of each are all comparable MailTrap has a free option too.

Related

Whenever tableau sends a data driven alert, I want to trigger an external API call

I am using Tableau Servers data driven alerts. Whenever our alerts threshold is passed, we send an email to users. However, I also want to call an external API from my application (not in tableau).
I have considered trying to use AWS SNS to trigger a lambda but was hoping to see if anyone else has faced a similar use case? It does not seem like Tableaus Rest APIs provide enough metadata to handle this use case for data driven alerts

How can I test sending of emails via SendGrid addon without damaging reputation?

I'm using the heroku SendGrid addon to send reminder emails on a schedule defined via heroku scheduler addon.
I want to do some live tests to make sure the heroku scheduler is configured correctly and the emails really send.
The problem is I have an app with a lot of dummy data. E.g. emails like something_random_ldskfj#example.com or just sldkfjsldfjsldkfj#example.com. I'm worried those emails sent will either go unread, bounce, or something else that SendGrid (or any mailing service) would consider 'negative', and that will mark my account as suspicious.
Question
How can I live test my app with heroku scheduler and make sure emails really send at the right times, without incurring the wrath of upsetting the mailing service?
What I've thought about doing
Setting up a lot of test gmail accounts - one for each dummy user (undesirable)
Sending to random emails like sldfjsd#example.com and not worrying about the potential consequences (very bad idea)
Setting up all the dummy accounts in my app with my own, personal email (cannot be done since the database enforces uniqueness of email)
Use some email addresses Heroku or SendGrid specifically provided for exactly this purpose? (sounds good if it exists?)
Altering all my test data so that the conditions for emails being sent will never met, except for a very small few (it would work, but it would require changing all the test data and therefore change the look and feel of the app)
After discussing with people more experienced than me, the advice I received was
If it's possible to send the emails only to yourself, then do that (not possible in my case)
No need to test heroku's scheduler (trust that it works)
Write really good tests to ensure the logic and code in your scheduled task works locally, and trust them - those test results mean it will work as expected in production

Deploy Hubot on AWS Lambda?

I'm a noob using Hubot, so please bear with me.
I was going through Hubot's documentation ( https://hubot.github.com/docs/deploying/ ) and saw that we can deploy to Heroku, Unix systems and others.
May I know how can Hubot be deployed on AWS Lambda ?
Best Regards.
I was wondering the same thing. I think the answer is probably "yes, if your chat system can send you http when traffic happens". I think Lambda is probably a great choice, since each message in chat is an event to process according to the rules that your bot has. So, the Lambda function invocation model is a good fit - lots of tiny invokes. You might, though, want to filter the traffic that gets to the function, though, if your chat system is high-traffic.
For example Slack's Events API lets you subscribe to all of the things you might need the bot to see, I think. You'd then need to route those requests to your lambda function, which you could do via AWS API Gateway.
The existing hubot-slack adapter uses the Real-Time Messaging API, though, so you'd need to write your own adaptor for the Events API http that the API Gateway receives.
The same approach (and requirement) applies to other chat systems.

Implications of allowing users to email content and attachments to a server

I have implemented a feature in my application that allows registered users to send an email to a gmail account, which my server polls using Spring Integration, and then if it recognises the sender, stores the subject and body content in a database (via JPA).
I also want to allow users to be able to send files as attachments to these emails which I plan to store on AWS.
I'm sure there must be security implications with both of these features, but I'm not aware of what they might be.
So my question is, what are the security implications of allowing users to store email content in my DB and attached files on AWS?
TIA
You could have some problems when you will have many emails to process using a single email account (probably not a problem at the beginning). Also making yourself dependent on an external email provider may sound for you clients really unreliable (depending on your clients/business). Also someone could eat up all your space on gmail by sending too many emails that don't get deleted on time. Also when storing the files in AWS you must store the files with random filenames. Probably you will have to read some tutorials for that.

Web application control through text messages

I want to develop an application that works by receiving text messages from users to gather data. I have no clue where to begin and what to begin with. I can code in Python, C++, PHP and can do Java also.
I was wondering if there can be a personal development setup or framework on which I can develop such application. Releasing it is a different story but I do not have any idea about what setup is needed to develop this application.
Also, how much would this setup cost? Are there open-source or any other cheap alternatives?
There are a lot of services out there that let you receive SMS via a web request. The one I work for Twilio will send you a simple POST request to a URL of your choice containing To, From and Body whenever you receive an incoming message. You can read more about how it works here.
This service offers an api for receiving text messages. You can use the shared number and send it to your server with a keyword or you can pay a monthy fee to have your own dedicated number. So there would be a good place to start.

Resources