Assuming I am creating an online service that allows my clients to
send email (using their SMTP credentials), what risks should I
consider and how to prevent them?
I'm going to infer that the question is, "What risks exist in creating a web application that utilizes a third-party SMTP service?"
You mention already that you're not using your own SMTP service, so you have a layer of concern to worry about prior to the possible IP Block listing. Will you be allowing your users to specify their own SMTP service provider? Or will you be using a dedicated third-party provider?
Risks
- SMTP provider may have e-mail throttling in place (i.e. 1000 e-mail sent per 1 day)
- SMTP provider may block SMTP requests coming from your web application
- The IP Address of your web application is block listed, which can indeed still happen even if the SMTP servers that you are using are not yours. Typically, e-mail headers will contain details of the origin of the e-mail in the X-Originating-IP e-mail header.
- Stolen credentials can be used to send spam, or malicious e-mail.
- User credentials may be at risk of theft if logged or stored in an insecure manner.
- Poorly configured headers. You'll need to put the e-mail together programmatically before sending to the SMTP server. Poorly configured email headers can lead to rejected e-mail.
Recommendations
- Use Multi-factor authentication, or an additional authentication mechanism, along with SMTP authentication.
- Use a dedicated, third-party SMTP provider and ensure you understand what they do and do not allow. Verify if they throttle e-mail, and what that throttling is.
- Throttle the ability to send e-mail by your users (i.e. 1000 e-mail sent per 1 day), within your third-party provider limits.
- Don't store your users credentials.
- SPF, DKIM, and DMARC are DNS frameworks that provide additional security and reporting capabilities related to e-mail; I would highly recommend you understand how your SMTP provider has these configured.
Recommended Reading
SIMPLE MAIL TRANSFER PROTOCOL - https://www.rfc-editor.org/rfc/rfc821.html
Sender Policy Framework (SPF) for Authorizing Use of Domains in E-Mail, Version 1 - https://www.rfc-editor.org/rfc/rfc4408.html
DomainKeys Identified Mail (DKIM) Signatures - https://www.rfc-editor.org/rfc/rfc7489.html
Domain-based Message Authentication, Reporting, and Conformance (DMARC) - https://www.rfc-editor.org/rfc/rfc7489.html