From 0c024b90f386d09c5fe57b356e7b540206997be2 Mon Sep 17 00:00:00 2001 From: Maly Date: Wed, 16 Dec 2020 19:41:42 +0900 Subject: [PATCH] =?UTF-8?q?[ADD]=20#13=20=EB=AC=B8=EC=9E=90=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infrastructure/sms/sms_service_impl.py | 28 ++++++++++++-------------- requirements.txt | 6 ++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/infrastructure/sms/sms_service_impl.py b/infrastructure/sms/sms_service_impl.py index 5d94b6c..78d114f 100644 --- a/infrastructure/sms/sms_service_impl.py +++ b/infrastructure/sms/sms_service_impl.py @@ -1,3 +1,5 @@ +import os + from domain.service.sms_service import SMSService from infrastructure.open_tracing import open_tracing from infrastructure.open_tracing.open_tracing_handler import trace_service @@ -6,19 +8,15 @@ class SMSServiceImpl(SMSService): @trace_service("SMS (send)", open_tracing) def send(self, target_number: str, message: str, x_request_id): - # Temporary - import os - import smtplib - from email.mime.text import MIMEText - - smtp = smtplib.SMTP('smtp.gmail.com', 587) - smtp.ehlo() - smtp.starttls() - smtp.login('frametemporary123@gmail.com', os.getenv("EMAIL_PASSWORD")) - - msg = MIMEText(message) - msg['Subject'] = 'SMS 테스트' - msg['To'] = 'dltjdqhr55@gmail.com' - smtp.sendmail('frametemporary123@gmail.com', 'dltjdqhr55@gmail.com', msg.as_string()) + import boto3 + client = boto3.client( + "sns", + aws_access_key_id=os.getenv("AWS_ACCESS_KEY"), + aws_secret_access_key=os.getenv("AWS_SECRET_KEY"), + region_name="ap-northeast-1" # 도쿄 + ) - smtp.quit() \ No newline at end of file + client.publish( + PhoneNumber="+82"+target_number, + Message=message + ) diff --git a/requirements.txt b/requirements.txt index 88985b9..811ee8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,24 @@ +boto3==1.16.37 +botocore==1.19.37 certifi==2020.6.20 cffi==1.14.4 chardet==3.0.4 cryptography==3.2.1 grpcio==1.33.1 +grpcio-tools==1.34.0 idna==2.10 jaeger-client==4.3.0 +jmespath==0.10.0 mysqlclient==2.0.1 opentracing==2.3.0 protobuf==3.13.0 pycparser==2.20 PyMySQL==0.10.1 python-consul==1.1.0 +python-dateutil==2.8.1 redis==3.5.3 requests==2.24.0 +s3transfer==0.3.3 six==1.15.0 SQLAlchemy==1.3.20 threadloop==1.0.2