Skip to content

Commit 0c5784b

Browse files
authored
Replace Pinpoint SMTP password with environment variable (#4745)
1 parent 48a5127 commit 0c5784b

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

.dotnet/example_code_legacy/Pinpoint/pinpoint_send_email_smtp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class MainClass
5454
static string ccAddress = "cc-recipient@example.com";
5555
static string bccAddress = "bcc-recipient@example.com";
5656

57-
// Replace smtp_username with your Amazon Pinpoint SMTP user name.
57+
// Replace smtp_username with your &PINlong; SMTP user name.
5858
static string smtpUsername = "AKIAIOSFODNN7EXAMPLE";
5959

60-
// Replace smtp_password with your Amazon Pinpoint SMTP password.
61-
static string smtpPassword = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
60+
// Use @ASMlong; to expose your &PIN; SMTP password.
61+
static string smtpPassword = System.getEnvironmentVariable("SMTP_PASSWORD");
6262

6363
// (Optional) the name of a configuration set to use for this message.
6464
static string configurationSet = "ConfigSet";

java/example_code/pinpoint/pinpoint_send_email_smtp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public class SendEmail {
5757
static final String ccAddresses = "cc-recipient0@example.com,cc-recipient1@example.com";
5858
static final String bccAddresses = "bcc-recipient@example.com";
5959

60-
// Replace smtp_username with your Amazon Pinpoint SMTP user name.
60+
// Replace smtp_username with your &PINlong; SMTP user name.
6161
static final String smtpUsername = "AKIAIOSFODNN7EXAMPLE";
6262

63-
// Replace smtp_password with your Amazon Pinpoint SMTP password.
64-
static final String smtpPassword = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
63+
// Use @ASMlong; to expose your &PIN; SMTP password.
64+
static string smtpPassword = System.getEnv("SMTP_PASSWORD");
6565

6666
// (Optional) the name of a configuration set to use for this message.
6767
static final String configurationSet = "ConfigSet";

javascript/example_code/pinpoint/pinpoint_send_email_smtp.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1111
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
1212
* specific language governing permissions and limitations under the License.
13-
*/
13+
*/
1414

1515
// snippet-sourcedescription:[pinpoint_send_email_smtp demonstrates how to send a transactional email message by using the Amazon Pinpoint SMTP interface and the Nodemailer module.]
1616
// snippet-service:[Amazon Pinpoint]
@@ -60,11 +60,11 @@ var toAddresses = "recipient@example.com";
6060
var ccAddresses = "cc-recipient0@example.com,cc-recipient1@example.com";
6161
var bccAddresses = "bcc-recipient@example.com";
6262

63-
// Replace smtp_username with your Amazon Pinpoint SMTP user name.
63+
// Replace smtp_username with your &PINlong; SMTP user name.
6464
const smtpUsername = "AKIAIOSFODNN7EXAMPLE";
6565

66-
// Replace smtp_password with your Amazon Pinpoint SMTP password.
67-
const smtpPassword = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
66+
// Use &ASMlong; to expose your &PIN; SMTP password.
67+
const smtpPassword = process.env["SMTP_PASSWORD"];
6868

6969
// (Optional) the name of a configuration set to use for this message.
7070
var configurationSet = "ConfigSet";
@@ -92,17 +92,16 @@ var body_html = `<html>
9292
var tag0 = "key0=value0";
9393
var tag1 = "key1=value1";
9494

95-
async function main(){
96-
95+
async function main() {
9796
// Create the SMTP transport.
9897
let transporter = nodemailer.createTransport({
9998
host: smtpEndpoint,
10099
port: port,
101100
secure: false, // true for 465, false for other ports
102101
auth: {
103102
user: smtpUsername,
104-
pass: smtpPassword
105-
}
103+
pass: smtpPassword,
104+
},
106105
});
107106

108107
// Specify the fields in the email.
@@ -116,20 +115,18 @@ async function main(){
116115
html: body_html,
117116
// Custom headers for configuration set and message tags.
118117
headers: {
119-
'X-SES-CONFIGURATION-SET': configurationSet,
120-
'X-SES-MESSAGE-TAGS': tag0,
121-
'X-SES-MESSAGE-TAGS': tag1
122-
}
118+
"X-SES-CONFIGURATION-SET": configurationSet,
119+
"X-SES-MESSAGE-TAGS": tag0,
120+
"X-SES-MESSAGE-TAGS": tag1,
121+
},
123122
};
124123

125124
// Send the email.
126-
let info = await transporter.sendMail(mailOptions)
125+
let info = await transporter.sendMail(mailOptions);
127126

128127
console.log("Message sent! Message ID: ", info.messageId);
129128
}
130129

131130
main().catch(console.error);
132131

133132
// snippet-end:[pinpoint.javascript.pinpoint_send_email_smtp.complete]
134-
135-

python/example_code/pinpoint/pinpoint_send_email_smtp.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from email.mime.multipart import MIMEMultipart
1313
from email.mime.text import MIMEText
14+
from os import environ
1415
import logging
1516
import smtplib
1617

@@ -77,13 +78,13 @@ def main():
7778
<a href='https://docs.python.org/3/library/smtplib.html'>
7879
smtplib</a> library.</p>
7980
</body>
80-
</html>
81-
"""
81+
</html>"""
8282

83-
# Replace smtp_username and smtp_password with your Amazon Pinpoint SMTP user name
84-
# and password.
83+
# Replace smtp_username your &PINlong; SMTP user name.
8584
smtp_username = "AKIAIOSFODNN7EXAMPLE"
86-
smtp_password = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
85+
86+
# Use &ASMlong; to expose your &PIN; SMTP password.
87+
smtp_password = environ["SMTP_PASSWORD"]
8788

8889
print("Sending email through SMTP server.")
8990
try:

0 commit comments

Comments
 (0)