AWS SES API Setup
Record knowledge for items resolved.
CloudFlare Domain + AWS SES API Creation
- Login AWS
- Under ap-southeast-1 go to SMTP Setting, Create SMTP credential. (It is different from AWS Access Key), Policy will be auto created under the credential.
- Verify the Domain or Email Address for receiving message
- Remove Sandbox setting
- Upscale Quota



Domain Creation

- Purchase Domain
- Create DNS records and email forward records
Code Testing
function SendEmail($Server, $Port, $Sender, $Recipient, $Subject, $Body) {
$Credentials = [Net.NetworkCredential](Get-Credential)
$SMTPClient = New-Object Net.Mail.SmtpClient($Server, $Port)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Credentials.Username, $Credentials.Password);
try {
Write-Output "Sending message..."
$SMTPClient.Send($Sender, $Recipient, $Subject, $Body)
Write-Output "Message successfully sent to $($Recipient)"
} catch [System.Exception] {
Write-Host "Error sending email: $($_.Exception.Message)"
Write-Output "An error occurred:"
Write-Output "Error Message: $($_.Exception.Message)"
Write-Output "Error Source: $($_.Exception.Source)"
Write-Output "Error Stack Trace: $($_.Exception.StackTrace)"
Write-Error $_
}
}
function SendTestEmail(){
$Server = "email-smtp.ap-southeast-1.amazonaws.com"
$Port = 587
$Subject = "Test email sent from Amazon SES"
$Body = "This message was sent from Amazon SES using PowerShell (explicit SSL, port 587)."
$Sender = "sender@yourdomain.com"
$Recipient = "anyone@gmail.com"
SendEmail $Server $Port $Sender $Recipient $Subject $Body
}
SendTestEmail

P.S. Create a new AccessKey2 will not work, please always create a new key for key rotation.
最新評論