Placing SQL Server generated emails in Outlook Outbox - sql-server

We send monthly emails generated in SQL Server(2017) using sp_send_dbmail to clients containing sensitive data. Recently, there's been a breach where a client received something they shouldn't have received. The cause of this is honestly just bad code, but going forward we want to be able to screen emails more effectively. We are now avoiding the sensitive data issue by asking clients to log in to our system to look at this data instead. Whilst this would be perfectly normal procedure, certain people demand everything in an email. It's a security problem, but the client wants what they want, and the head honcho wants to give the client what they want.
We use Outlook, which has an outbox that nobody really uses anymore as far as I know. Is there a way to get SQL Server to place emails into a shared outbox account so that we can screen emails that contain sensitive data before we send them out?
For initial QA, data for emails containing alerts are generated via stored procedures and sent to QA analysts to check over. This is done by manually setting the recipients to the QA analysts for emails to all clients.
We don't expect them to cover every email as that would be insane, so we ask that they check a random selection to be confident enough that the data is accurate.
Once they are happy, we run the stored procedures again but we pass a parameter so that it cursors through a table that contains every email alert for each client and generates the tailored email for each client and is sent using sp_send_dbmail.
In other words, the email being screened by the QA analysts might not be the same as the email send to clients. This is how the breach occurred.
If we had a way to get these emails into a shared outbox, the QA work can be done on that shared outbox and then we can send the emails. Asking someone to hit send for a big bunch of emails would still be a pain, but perhaps a little less so than having another breach.

AFAIK sp_send_dbmail uses SMTP to send messages. If you want to place messages in the Drafts (or any other) folder of a particular mailbox, you will need to create messages (without sending) using Graph or EWS.

Related

Storing users IP address in a DB in order to compare it later on

I'm quite new to React and after doing a Todo web app I've tried creating my first fullstack web app.
The app sends a request upon entering an Email and pressing a button that should send the users mail to a DB and get his IP which would also be stored into the same DB. This would later be used to check if the user had already done something on the site (After entering the email the client-s sent to the next page) and disallow the user to proceed if either the email or IP are already stored in the DB. What would be the best way to both grab the IP upon entering the email and what would be the best approach in regards of storing it into a DB? (Should I even store it there is there a better alternative).
I'm writing my code with Typescriptx and using Express for my backend & postgres for my DB.
TLDR: How to get the clients IP onClick / upon recieveing a request from them and store it in a database to later compare when the user sends the same request again
On the server side, you can get the IP address from the incoming request. That's the right way to do this (but see below: I think you probably don't want to do this).
In express, this is available via req.socket.remoteAddress. If you're behind some kind of reverse proxy like a CDN then this will give you the CDN's IP, not the real user, but all modern proxies will include the original IP in a request header such as X-Forwarded-For to work around this. You can get the IP from there instead, if that's present. You'll need to look at the docs for your specific infrastructure to check the header they use in this case.
That said, it sounds like you're trying to ensure each user can do exactly one thing, so that after sending an email nothing else is allowed. Is that right?
If that's the case, limiting it by IP address isn't a great solution. Two reasons:
Many users share an IP address, e.g. many many mobile users who are behind CGNAT, everybody sharing an office/home, etc etc
At the same time, many users have multiple IP addresses, e.g. offices that use multiple internet connections in parallel for failover or performance, or people taking their computer from their home to a cafe, etc etc.
In both cases, you'll end up blocking or allowing large numbers of users incorrectly. Typically this kind of thing is done with cookies/local storage on the client side instead, which lets you block this individual user's browser. That will work correctly in environments with shared IPs and environments with multiple IPs.
A client-side approach is not 100% secure, since a technical user could easily clear their cookies to avoid this. If you need a hard guarantee though then neither option would work (it's easy to change your IP too: go sit in the coffee shop outside, or use your phone as a hotspot). In that case, you need to tie the user to something they can't as easily change, maybe an email address, credit card, or even legal ID if you're seriously trying to lock this down hard.
I wouldn't bother: for most web app, client-side storage is usually the right choice.

Send e-mail if someone execute any query on the database

Basically, whenever the user execute any query(for example: SELECT query), I want the user get instantly notified by email that he or she has executed this(the full query he just used) query. The reason I want this because the data can be confidential, so for the security purpose. Thank you.
I would advise against using this approach.
If the data is confidential sending the mail after it has been retrieved seems to be too late. During nights it can take hours until such a mail is read and during vacations it can take days or even weeks. Also imagine checking 100s of mails each day which mostly contain unsuspicious querys. It's a headache.
Better set your database up so that confidential data can not be retrieved by personal which is not authorized to do so.
If you really want to set up a trigger for sending E-Mails you might want to take a look at this answer: Send e-mail from a trigger

Synchronizing Clients with Gmail

What is Synchronizing client with gmail ? Can anybody give a detailed explanation, because i want to have a better understanding over this concept.
For example, if your client keeps any local cache of the Gmail mailbox data like the Message.Id and labels, or headers, or the entire email. Then in order to update your client you're synchronizing it with Gmail--pulling new updates down to your client. In cases of clients designed for offline use, then synchronizing may also mean pushing local updates back up to the server (e.g. label updates made by client while "offline" that get applied at some later point). That's the general definition of synchronizing.
For the Gmail API specific case, Gmail has a backend mailbox-wide history Id. Any change that affects that account in any way gets a history identifier and most (but not all) history changes affect the state of email messages. Like adding a new message, changing the labels on a message, or deleting a message. Clients of the Gmail API can poll the history Id and find out what's changed since the last time they synchronized and pull down updates to maintain their sync.

How do we get App Engine to email an invite to be a developer?

Someone invited me to be a developer on his app. I did not get the email invite?
I have had others invite me and it works (and works well!)
We got around the problem by having an invite sent to another account. That works for now, but I really need the invite to be sent to the correct account.
Gary
The question is borderline off-topic in that it's not usually a programming question, but it comes up so often, from programmers and the customers we support, that I wanted to put an answer here in the hopes that it would be helpful.
I see that it was in your spam folder, which is one of the more common causes of "lost" emails.
In short, when an email is sent from one server, it goes through several other servers and routers on the way to the final user's PC.
Any one of the following conditions could cause a sent email to not reach a recipient:
Blocked Outbound Mail - The sender's company/business/ISP has email scanning software that scans outbound email, and blocks suspicious outbound emails.
Our workplace has this to limit sensitive data being sent out accidentally, to block outbound infected emails sent from infected PCs.
Relay Server Permissions/Configuration - Your code is sending through a relay server that has rules blocking unauthorized use of email relay functionality.
In most shops with good security consciousness, email servers are configured to disallow email relay except for known IP addresses and/or known, explicitly authorized users.
External party blocks the email - The sender's company has been blacklisted.
Blocked Inbound Mail - The receivers company has email scanning software that scans incoming email (similar to #1) to block malicious/non-work related/bad emails from reaching the recipient's inbox.
Receiver's Spam Filtering - The receiver's email inbox has spam mail filtering, which may automatically move the email to a spam folder, delete them, or other action depending on how you have it configured.
Receiver's Inbound Mail Rules - Similar to the above. The recipient may have rules defined that block, delete, or move emails.
Outlook allows this, as do other email clients. Emails can match the patterns set for existing rules and result in false positives that trigger the rule execution.
Human error - the sender sent the email to the wrong email address.
Human error - the recipient accidentally deleted the email and just didn't see it. (You'd be surprised how often I've seen this.)
Bad programming - there was an error sending the email, but the exception handling ignores the error, so nobody ever knows any better.
Only #9 is actually a programming issue, and it's also (in my experience) the least common. Odds are that the problem has nothing to do with code that you'd be writing.
I'm sure there are more, but these are the ones I've seen the most frequently. I'll add as I think of others.

Sending Programmatic Email Messages

I'm looking to send email messages programmatically from my websites. For example, if people register their email address, I would like to email them to confirm their email address. To do this I will need to use an email sending tool and plug into an smtp service. In the past (7 or so years ago) I used Jmail, however, I am not sure what are the best services to use today and how spam filters have envolved!
I have three specific questions:
Does it matter which service I use to send emails programmatically (e.g., PhpMail, Jmail, etc.)? If so, which tools would you recommend?
How should I host this tool? I plan on sending a large volume of emails (thousands to hundreds of thousands). Would it make sense to use google-app-engine mail service to do this, or should I just host it on my own server (e.g., have my own SMTP server)?
I don't want my emails to be sent to spam folders, how can I ensure that the emails are received by the users?
Thanks!
No, you don't need your own. Based on the tags of your message, I'm going to assume you are using java and deploying your app on Google App Engine?
http://code.google.com/appengine/docs/java/mail/

Resources