-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly mailer fixes + improvements. - Issue where globalFrom was taking precedence over explicitly defined from email address in code - Adds ability to assign "sender" field (breaking change to custom mailer) - Added globalFrom documentation - Sender documentation
- Loading branch information
Showing
17 changed files
with
206 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ async Task SendMailCustomAsync( | |
MailRecipient replyTo, | ||
IEnumerable<MailRecipient> cc, | ||
IEnumerable<MailRecipient> bcc, | ||
IEnumerable<Attachment> attachments = null | ||
IEnumerable<Attachment> attachments = null, | ||
MailRecipient sender = null | ||
) | ||
{ | ||
// Custom logic for sending an email. | ||
|
@@ -111,6 +112,10 @@ async Task SendMailCustomAsync( | |
services.AddCustomMailer(this.Configuration, SendMailCustomAsync); | ||
``` | ||
|
||
:::warn | ||
Breaking changes to this method signature are more likely than other as this is the signature that the Mailer's internals use. If a new version of the Mailer causes your code to stop compiling sucessfully, it's probably this signature that needs to be updated. Luckliy, it's usually a quick change in 1 spot. | ||
::: | ||
|
||
### Built-In View Templates | ||
|
||
Coravel's mailer comes with some pre-built e-mail friendly razor templates! This means you don't have to worry about | ||
|
@@ -134,7 +139,7 @@ What about static content like the mail footer and logo? Coravel's got you cover | |
|
||
In your `appsettings.json`, you may add the following global values that will populate when using Coravel's built-in templates: | ||
|
||
``` | ||
```json | ||
"Coravel": { | ||
"Mail": { | ||
/* Your app's logo that will be shown at the top of your e-mails. */ | ||
|
@@ -195,35 +200,53 @@ You can then call various methods like `To` and `From` to configure the recipien | |
|
||
### From | ||
|
||
To specify who the sender of the email is, use the `From()` method: | ||
To specify who the email is from, use the `From()` method: | ||
|
||
`From("[email protected]")` | ||
```csharp | ||
From("[email protected]") | ||
``` | ||
|
||
You may also supply an instance of `Coravel.Mailer.Mail.MailRecipient` to include the address and sender name: | ||
|
||
`From(new MailRecipient(email, name))` | ||
```csharp | ||
From(new MailRecipient(email, name)) | ||
``` | ||
|
||
### Send To Recipient | ||
You can set a global from address by setting it in `appsettings.json`: | ||
|
||
Using the `To()` method, you can supply the recipient's e-mail address and name. | ||
|
||
#### Address | ||
```json | ||
"Coravel": { | ||
"Mail": { | ||
"From":{ | ||
"Address": "[email protected]", | ||
"Name": "My Company" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Using an e-mail address in a `string`: | ||
### To | ||
|
||
`To("[email protected]")` | ||
Using the `To()` method, you can supply the recipient's e-mail address and name. | ||
|
||
#### Multiple Addresses | ||
Or, using an e-mail address in a `string`: | ||
|
||
You can pass`IEnumerable<string>` to the `To()` method. | ||
```csharp | ||
To("[email protected]") | ||
``` | ||
|
||
#### MailRecipient | ||
You can also pass: | ||
- `To(IEnumerable<string>)` | ||
- `To(MailRecipient)` | ||
- `To(IEnumerable<MailRecipient>)` | ||
|
||
Pass an instance of `MailRecipient` to the `To()` method. | ||
### Sender | ||
|
||
#### Multiple MailRecipients | ||
To specify the sender of the email (different from the `From` address), use the `Sender()` method: | ||
|
||
Pass an `IEnumerable<MailRecipient>` to the `To()` method. | ||
```csharp | ||
Sender("[email protected]") | ||
``` | ||
|
||
#### Attachments | ||
|
||
|
@@ -261,18 +284,16 @@ Further methods, which all accept either `IEnumerable<string>` or `IEnumerable<M | |
|
||
##### .NET Core 3.1+ | ||
|
||
In .NET Core 3.1 there were some breaking changes to the way razor views are handled. | ||
For a standard .NET 6+ web project, this should work out-of-the-box. If using a shared library, the following applies. | ||
|
||
Which ever project(s) you have razor views inside, you'll need to make sure .NET compiles them at build time. | ||
In .NET Core 3.1 there were some breaking changes to the way razor views are handled. | ||
|
||
Here's what you'll need to change within your `.csproj` file to enable this: | ||
If you have a shared library with razor views inside, you'll need to make sure .NET compiles them at build time by adding the following to your `.csproj`: | ||
|
||
```xml | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> 👈 Make sure it's this SDK. | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<AddRazorSupportForMvc>True</AddRazorSupportForMvc> 👈 Add this too. | ||
</PropertyGroup> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.