|
1 | | -# EmailService |
2 | | -Email micro service |
| 1 | +## EmailService |
| 2 | +Email micro service. |
| 3 | +It's a simple service just to send emails. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +.Net Core 3.1 |
| 8 | + |
| 9 | +## Configuration |
| 10 | + |
| 11 | +In ```src/EmailService/appsettings.json``` file add this configuration |
| 12 | +```js |
| 13 | +{ |
| 14 | + // configuration omitted |
| 15 | + "EmailSenderOptions": { |
| 16 | + "Email": "email address from which your service will send emails. example@gmail.com", |
| 17 | + "Password": "password for email address from which your service will send emails. superhardpassword", |
| 18 | + "SmtpHost": "smtp server or some another host. smtp.mail.ru", |
| 19 | + "SmtpPort": 25 //Use your smtp port |
| 20 | + }, |
| 21 | + "HeaderAuthorizationOptions": { |
| 22 | + "Key": "some random key for Header Authoriztion" |
| 23 | + } |
| 24 | + // configuration omitted |
| 25 | +} |
| 26 | +``` |
| 27 | +## Run |
| 28 | +```bash |
| 29 | +cd ./src/EmailService |
| 30 | +dotnet run |
| 31 | +``` |
| 32 | +API will be available on [localhost:5000](http://localhost:5000) |
| 33 | + |
| 34 | +## How to use |
| 35 | + |
| 36 | +There is one available POST request on url /api/email/send. |
| 37 | +Request body (__all__ fields are __required__!): |
| 38 | +```js |
| 39 | +{ |
| 40 | + "Email": "email address to which send email. test@test.com", |
| 41 | + "Subject": "email's subject. My first Test subject", |
| 42 | + "Body": "email's message in html. Just a test mail.<br>Second line." |
| 43 | +} |
| 44 | +``` |
| 45 | +### curl exampple how to send email |
| 46 | +Email address which would receive email: example@mail.ru |
| 47 | +Subject of email: Confirm your email |
| 48 | +Body of email: ``` Please visit this <a>link</a> to confirm your email.``` |
| 49 | +```bash |
| 50 | +curl --header "Content-Type: application/json" \ |
| 51 | + --header "Authorization: some random key for Header Authoriztion" |
| 52 | + --request POST \ |
| 53 | + --data '{"email":"example@mail.ru","subject":"Confirm your email", "body":"Please visit this <a>link</a> to confirm your email."}' \ |
| 54 | + http://localhost:5000/api/email/send |
| 55 | +``` |
0 commit comments