-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into filip-ts-sdk
- Loading branch information
Showing
9 changed files
with
46 additions
and
24 deletions.
There are no files selected for viewing
23 changes: 16 additions & 7 deletions
23
waspc/data/Generator/templates/sdk/wasp/server/email/core/providers/mailgun.ts
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 |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import { NodeMailgun } from "ts-mailgun"; | ||
import Mailgun from 'mailgun.js'; | ||
import { getDefaultFromField } from "../helpers.js"; | ||
import type { MailgunEmailProvider, EmailSender } from "../types"; | ||
|
||
// PRIVATE API | ||
export function initMailgunEmailSender( | ||
config: MailgunEmailProvider | ||
): EmailSender { | ||
const mailer = new NodeMailgun(config.apiKey, config.domain); | ||
|
||
const defaultFromField = getDefaultFromField(); | ||
|
||
const mailgun = new Mailgun(FormData); | ||
|
||
const mailer = mailgun.client({ | ||
username: 'api', | ||
key: config.apiKey, | ||
url: config.apiUrl, | ||
}); | ||
|
||
return { | ||
async send(email) { | ||
const fromField = email.from || defaultFromField; | ||
mailer.fromEmail = fromField.email; | ||
mailer.fromTitle = fromField.name; | ||
mailer.init(); | ||
return mailer.send(email.to, email.subject, email.html); | ||
return mailer.messages.create(config.domain, { | ||
from: `${fromField.name} <${fromField.email}>`, | ||
to: [email.to], | ||
subject: email.subject, | ||
text: email.text, | ||
html: email.html, | ||
}) | ||
}, | ||
}; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...spComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/email/core/types.d.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...puts/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/server/email/core/types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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