« Previous section Next section »
UCloud Developer Guide / Core / Communication / Mail
Mail
Internal service for sending e-mails.
Rationale
Currently only one end-point is exposed for sending a single email to one user at a time, and only SERVICE
principals is authorized to do so. The endpoint does take multiple mails as a bulk request, but they are sent individually
Email templates are pre-defined and are not controllable by clients.
Table of Contents
1. Examples 2. Remote Procedure Calls 3. Data Models Example: Sending an email
Frequency of use Common
The UCloud/Core service user (ucloud
)
Communication Flow: Kotlin
Copy MailDescriptions.sendToUser. call (
bulkRequestOf ( SendRequestItem (
mail = Mail. LowFundsMail (
categories = listOf ( "u1-standard" ),
projectTitles = listOf ( "Science Project" ),
providers = listOf ( "ucloud" ),
subject = "Wallets low on resource" ,
),
mandatory = false ,
receiver = "User#1234" ,
receivingEmail = null ,
testMail = null ,
)),
ucloud
). orThrow ()
/*
Unit
*/
Communication Flow: Curl
Copy # ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as ucloud
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/sendToUser" -d '{
"items" : [
{
"receiver" : "User#1234" ,
"mail" : {
"type" : "lowFunds" ,
"categories" : [
"u1-standard"
],
"providers" : [
"ucloud"
],
"projectTitles" : [
"Science Project"
],
"subject" : "Wallets low on resource"
},
"mandatory" : false ,
"receivingEmail" : null,
"testMail" : null
}
]
}'
# {
# }
Communication Flow: VisualExample: Forwarding a support ticket to Jira
Frequency of use Common
The UCloud/Core service user (ucloud
)
Communication Flow: Kotlin
Copy MailDescriptions.sendSupport. call (
SendSupportEmailRequest (
fromEmail = "foo@bar" ,
message = "Message" ,
subject = "Subject" ,
),
ucloud
). orThrow ()
/*
Unit
*/
Communication Flow: Curl
Copy # ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as ucloud
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/support" -d '{
"fromEmail" : "foo@bar" ,
"subject" : "Subject" ,
"message" : "Message"
}'
# {
# }
Communication Flow: VisualExample: Changing e-mail settings
Frequency of use Common
An authenticated user (user
)
Communication Flow: Kotlin
Copy MailDescriptions.retrieveEmailSettings. call (
RetrieveEmailSettingsRequest (
username = null ,
),
user
). orThrow ()
/*
RetrieveEmailSettingsResponse(
settings = EmailSettings(
applicationStatusChange = true,
applicationTransfer = true,
grantApplicationApproved = true,
grantApplicationRejected = true,
grantApplicationUpdated = true,
grantApplicationWithdrawn = true,
lowFunds = true,
newCommentOnApplication = true,
newGrantApplication = true,
projectUserInvite = true,
projectUserRemoved = true,
userLeft = true,
userRoleChange = true,
verificationReminder = true,
),
)
*/
MailDescriptions.toggleEmailSettings. call (
bulkRequestOf ( EmailSettingsItem (
settings = EmailSettings (
applicationStatusChange = true ,
applicationTransfer = true ,
grantApplicationApproved = true ,
grantApplicationRejected = true ,
grantApplicationUpdated = true ,
grantApplicationWithdrawn = true ,
lowFunds = true ,
newCommentOnApplication = true ,
newGrantApplication = true ,
projectUserInvite = true ,
projectUserRemoved = true ,
userLeft = true ,
userRoleChange = true ,
verificationReminder = false ,
),
username = null ,
)),
user
). orThrow ()
/*
Unit
*/
MailDescriptions.retrieveEmailSettings. call (
RetrieveEmailSettingsRequest (
username = null ,
),
user
). orThrow ()
/*
RetrieveEmailSettingsResponse(
settings = EmailSettings(
applicationStatusChange = true,
applicationTransfer = true,
grantApplicationApproved = true,
grantApplicationRejected = true,
grantApplicationUpdated = true,
grantApplicationWithdrawn = true,
lowFunds = true,
newCommentOnApplication = true,
newGrantApplication = true,
projectUserInvite = true,
projectUserRemoved = true,
userLeft = true,
userRoleChange = true,
verificationReminder = false,
),
)
*/
Communication Flow: Curl
Copy # ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as user
curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/mail/retrieveEmailSettings?"
# {
# "settings": {
# "newGrantApplication": true,
# "grantApplicationUpdated": true,
# "grantApplicationApproved": true,
# "grantApplicationRejected": true,
# "grantApplicationWithdrawn": true,
# "newCommentOnApplication": true,
# "applicationTransfer": true,
# "applicationStatusChange": true,
# "projectUserInvite": true,
# "projectUserRemoved": true,
# "verificationReminder": true,
# "userRoleChange": true,
# "userLeft": true,
# "lowFunds": true
# }
# }
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/toggleEmailSettings" -d '{
"items" : [
{
"username" : null,
"settings" : {
"newGrantApplication" : true ,
"grantApplicationUpdated" : true ,
"grantApplicationApproved" : true ,
"grantApplicationRejected" : true ,
"grantApplicationWithdrawn" : true ,
"newCommentOnApplication" : true ,
"applicationTransfer" : true ,
"applicationStatusChange" : true ,
"projectUserInvite" : true ,
"projectUserRemoved" : true ,
"verificationReminder" : false ,
"userRoleChange" : true ,
"userLeft" : true ,
"lowFunds" : true
}
}
]
}'
# {
# }
curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/mail/retrieveEmailSettings?"
# {
# "settings": {
# "newGrantApplication": true,
# "grantApplicationUpdated": true,
# "grantApplicationApproved": true,
# "grantApplicationRejected": true,
# "grantApplicationWithdrawn": true,
# "newCommentOnApplication": true,
# "applicationTransfer": true,
# "applicationStatusChange": true,
# "projectUserInvite": true,
# "projectUserRemoved": true,
# "verificationReminder": false,
# "userRoleChange": true,
# "userLeft": true,
# "lowFunds": true
# }
# }
Communication Flow: VisualRemote Procedure Calls
retrieveEmailSettings
Changes an end-user's e-mail preferences
sendDirect
sendSupport
Forwards a support ticket into Jira
NOTE: This endpoint is meant only for use by SDU and might not work well with other deployments.
sendToUser
Sends an email to an end-user based on a pre-defined template
toggleEmailSettings
Retrieves an end-user's e-mail preferences
Data Models
EmailSettings
Copy data class EmailSettings (
val newGrantApplication: Boolean ?,
val grantApplicationUpdated: Boolean ?,
val grantApplicationApproved: Boolean ?,
val grantApplicationRejected: Boolean ?,
val grantApplicationWithdrawn: Boolean ?,
val newCommentOnApplication: Boolean ?,
val applicationTransfer: Boolean ?,
val applicationStatusChange: Boolean ?,
val projectUserInvite: Boolean ?,
val projectUserRemoved: Boolean ?,
val verificationReminder: Boolean ?,
val userRoleChange: Boolean ?,
val userLeft: Boolean ?,
val lowFunds: Boolean ?,
)
PropertiesEmailSettingsItem
Copy data class EmailSettingsItem (
val username: String ?,
val settings: EmailSettings ,
)
PropertiesMail
Copy sealed class Mail {
abstract val subject: String
class GrantApplicationApproveMail : Mail ()
class GrantApplicationApproveMailToAdmins : Mail ()
class GrantApplicationRejectedMail : Mail ()
class GrantApplicationStatusChangedToAdmin : Mail ()
class GrantApplicationUpdatedMail : Mail ()
class GrantApplicationUpdatedMailToAdmins : Mail ()
class GrantApplicationWithdrawnMail : Mail ()
class LowFundsMail : Mail ()
class NewCommentOnApplicationMail : Mail ()
class NewGrantApplicationMail : Mail ()
class ProjectInviteMail : Mail ()
class ResetPasswordMail : Mail ()
class StillLowFundsMail : Mail ()
class TransferApplicationMail : Mail ()
class UserLeftMail : Mail ()
class UserRemovedMail : Mail ()
class UserRemovedMailToUser : Mail ()
class UserRoleChangeMail : Mail ()
class VerificationReminderMail : Mail ()
class VerifyEmailAddress : Mail ()
}
PropertiesMail.GrantApplicationApproveMail
Copy data class GrantApplicationApproveMail (
val projectTitle: String ,
val subject: String ?,
val type: String /* "applicationApproved" */ ,
)
PropertiesMail.GrantApplicationApproveMailToAdmins
Copy data class GrantApplicationApproveMailToAdmins (
val sender: String ,
val projectTitle: String ,
val subject: String ?,
val type: String /* "applicationApprovedToAdmins" */ ,
)
PropertiesMail.GrantApplicationRejectedMail
Copy data class GrantApplicationRejectedMail (
val projectTitle: String ,
val subject: String ?,
val type: String /* "applicationRejected" */ ,
)
PropertiesMail.GrantApplicationStatusChangedToAdmin
Copy data class GrantApplicationStatusChangedToAdmin (
val status: String ,
val projectTitle: String ,
val sender: String ,
val receivingProjectTitle: String ,
val subject: String ?,
val type: String /* "applicationStatusChangedToAdmins" */ ,
)
PropertiesMail.GrantApplicationUpdatedMail
Copy data class GrantApplicationUpdatedMail (
val projectTitle: String ,
val sender: String ,
val subject: String ?,
val type: String /* "applicationUpdated" */ ,
)
PropertiesMail.GrantApplicationUpdatedMailToAdmins
Copy data class GrantApplicationUpdatedMailToAdmins (
val projectTitle: String ,
val sender: String ,
val receivingProjectTitle: String ,
val subject: String ?,
val type: String /* "applicationUpdatedToAdmins" */ ,
)
PropertiesMail.GrantApplicationWithdrawnMail
Copy data class GrantApplicationWithdrawnMail (
val projectTitle: String ,
val sender: String ,
val subject: String ?,
val type: String /* "applicationWithdrawn" */ ,
)
PropertiesMail.LowFundsMail
Copy data class LowFundsMail (
val categories: List < String >,
val providers: List < String >,
val projectTitles: List < String >,
val subject: String ?,
val type: String /* "lowFunds" */ ,
)
Properties
Copy data class NewCommentOnApplicationMail (
val sender: String ,
val projectTitle: String ,
val receivingProjectTitle: String ,
val subject: String ?,
val type: String /* "newComment" */ ,
)
PropertiesMail.NewGrantApplicationMail
Copy data class NewGrantApplicationMail (
val sender: String ,
val projectTitle: String ,
val subject: String ?,
val type: String /* "newGrantApplication" */ ,
)
PropertiesMail.ProjectInviteMail
Copy data class ProjectInviteMail (
val projectTitle: String ,
val subject: String ?,
val type: String /* "invitedToProject" */ ,
)
PropertiesMail.ResetPasswordMail
Copy data class ResetPasswordMail (
val token: String ,
val subject: String ?,
val type: String /* "resetPassword" */ ,
)
PropertiesMail.StillLowFundsMail
Copy data class StillLowFundsMail (
val category: String ,
val provider: String ,
val projectTitle: String ,
val subject: String ?,
val type: String /* "stillLowFunds" */ ,
)
PropertiesMail.TransferApplicationMail
Copy data class TransferApplicationMail (
val senderProject: String ,
val receiverProject: String ,
val applicationProjectTitle: String ,
val subject: String ?,
val type: String /* "transferApplication" */ ,
)
PropertiesMail.UserLeftMail
Copy data class UserLeftMail (
val leavingUser: String ,
val projectTitle: String ,
val subject: String ?,
val type: String /* "userLeft" */ ,
)
PropertiesMail.UserRemovedMail
Copy data class UserRemovedMail (
val leavingUser: String ,
val projectTitle: String ,
val subject: String ?,
val type: String /* "userRemoved" */ ,
)
PropertiesMail.UserRemovedMailToUser
Copy data class UserRemovedMailToUser (
val projectTitle: String ,
val subject: String ?,
val type: String /* "userRemovedToUser" */ ,
)
PropertiesMail.UserRoleChangeMail
Copy data class UserRoleChangeMail (
val subjectToChange: String ,
val roleChange: String ,
val projectTitle: String ,
val subject: String ?,
val type: String /* "userRoleChange" */ ,
)
PropertiesMail.VerificationReminderMail
Copy data class VerificationReminderMail (
val projectTitle: String ,
val role: String ,
val subject: String ?,
val type: String /* "verificationReminder" */ ,
)
PropertiesMail.VerifyEmailAddress
Copy data class VerifyEmailAddress (
val verifyType: String ,
val token: String ,
val subject: String ?,
val username: String ?,
val type: String /* "verifyEmailAddress" */ ,
)
PropertiesRetrieveEmailSettingsRequest
Copy data class RetrieveEmailSettingsRequest (
val username: String ?,
)
PropertiesSendDirectMandatoryEmailRequest
Copy data class SendDirectMandatoryEmailRequest (
val recipientEmail: String ,
val mail: Mail ,
)
PropertiesSendRequestItem
Copy data class SendRequestItem (
val receiver: String ,
val mail: Mail ,
val mandatory: Boolean ?,
val receivingEmail: String ?,
val testMail: Boolean ?,
)
PropertiesSendSupportEmailRequest
Copy data class SendSupportEmailRequest (
val fromEmail: String ,
val subject: String ,
val message: String ,
)
PropertiesRetrieveEmailSettingsResponse
Copy data class RetrieveEmailSettingsResponse (
val settings: EmailSettings ,
)
Properties