danzuep / MailKitSimplified

Send and receive emails easily, fluently, with one line of code for each operation.
MIT License
79 stars 10 forks source link

Add DefaultFrom #24

Closed staoran closed 1 year ago

staoran commented 1 year ago

1 : Add DefaultFrom method missing in IEmailWriter interface. 2 : Add the DefaultFrom attribute to EmailSenderOptions, and you can use the "await _writeEmail.To("test@localhost").SendAsync();" method directly without using the From method.

danzuep commented 1 year ago

I started adding DefaultFrom but never finished the UAT side of it, so thanks for the pull request! There's actually a growing list of features like this that I've implemented but haven't added to the wiki (or the interface) because I haven't tried them in a production environment yet.

danzuep commented 1 year ago

I think part of the reason why I didn't add this was because what if you want to reuse the subject line as well? Or an attachment? This is a much more likely scenario, but in those cases you can use the email.Copy() method. I'll merge this anyway though as now I know at least one person will use that feature.

staoran commented 1 year ago

But you mentioned that you have completed similar functions, we can completely accept the version you have already done. The reason I want this functionality is because my needs are particularly simple. I only use the function of sending mail. Send an email to myself when the program generates an exception, so I want to let me write less code through configuration items. 😄I'm so lazy.

danzuep commented 1 year ago

Haha if the definition of lazy is "achieving maximum benefit from minimum effort" then we should all stive to be more lazy!

danzuep commented 1 year ago

I've made some changes to bring it more in line with the receiver library, try the new alpha release and give me a thumbs up if it's all good.