sendEmail method
Future<void>
sendEmail({
- required String token,
- required ServerpodCloudEmailType emailType,
- required String email,
- required String projectName,
- required String authCode,
Sends a transactional email through the Serverpod Cloud email service.
Throws a ServerpodCloudEmailException if the service does not respond
with a 200 status code.
Implementation
Future<void> sendEmail({
required final String token,
required final ServerpodCloudEmailType emailType,
required final String email,
required final String projectName,
required final String authCode,
}) async {
final response = await _httpClient
.post(
Uri.parse('$baseUrl/api/email/send'),
headers: const {'Content-Type': 'application/json'},
body: jsonEncode({
'token': token,
'emailType': emailType.wireValue,
'email': email,
'projectName': projectName,
'authCode': authCode,
}),
)
.timeout(timeout);
if (response.statusCode == 200) {
return;
}
throw ServerpodCloudEmailException(
response.statusCode,
_tryParseError(response.body),
);
}