Memverifikasi identitas email dengan Amazon SES menggunakanAWS SDK - Amazon Simple Email Service

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Memverifikasi identitas email dengan Amazon SES menggunakanAWS SDK

Contoh kode berikut menunjukkan cara memverifikasi identitas email dengan Amazon SES.

.NET
AWS SDK for .NET
catatan

Masih ada lagi GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di AWSCode Examples Repository.

/// <summary> /// Starts verification of an email identity. This request sends an email /// from Amazon SES to the specified email address. To complete /// verification, follow the instructions in the email. /// </summary> /// <param name="recipientEmailAddress">Email address to verify.</param> /// <returns>True if successful.</returns> public async Task<bool> VerifyEmailIdentityAsync(string recipientEmailAddress) { var success = false; try { var response = await _amazonSimpleEmailService.VerifyEmailIdentityAsync( new VerifyEmailIdentityRequest { EmailAddress = recipientEmailAddress }); success = response.HttpStatusCode == HttpStatusCode.OK; } catch (Exception ex) { Console.WriteLine("VerifyEmailIdentityAsync failed with exception: " + ex.Message); } return success; }
JavaScript
untuk SDK JavaScript (v3)
catatan

Masih ada lagi GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di AWSCode Examples Repository.

// Import required AWS SDK clients and commands for Node.js import { VerifyEmailIdentityCommand } from "@aws-sdk/client-ses"; import { sesClient } from "./libs/sesClient.js"; const EMAIL_ADDRESS = "name@example.com"; const createVerifyEmailIdentityCommand = (emailAddress) => { return new VerifyEmailIdentityCommand({ EmailAddress: emailAddress }); }; const run = async () => { const verifyEmailIdentityCommand = createVerifyEmailIdentityCommand(EMAIL_ADDRESS); try { return await sesClient.send(verifyEmailIdentityCommand); } catch (err) { console.log("Failed to verify email identity.", err); return err; } };
Python
SDK for Python (Boto3)
catatan

Masih ada lagi GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di AWSCode Examples Repository.

class SesIdentity: """Encapsulates Amazon SES identity functions.""" def __init__(self, ses_client): """ :param ses_client: A Boto3 Amazon SES client. """ self.ses_client = ses_client def verify_email_identity(self, email_address): """ Starts verification of an email identity. This function causes an email to be sent to the specified email address from Amazon SES. To complete verification, follow the instructions in the email. :param email_address: The email address to verify. """ try: self.ses_client.verify_email_identity(EmailAddress=email_address) logger.info("Started verification of %s.", email_address) except ClientError: logger.exception("Couldn't start verification of %s.", email_address) raise

Untuk daftar lengkap panduan pengembangAWS SDK dan contoh kode, lihatMenggunakan Amazon SES denganAWS SDK. Topik ini juga mencakup informasi tentang memulai dan detail tentang versi SDK sebelumnya.