Skip to content

Commit

Permalink
[ADD] #13 문자 서비스 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
mallycrip committed Dec 16, 2020
1 parent 170d3d5 commit 0c024b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
28 changes: 13 additions & 15 deletions infrastructure/sms/sms_service_impl.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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('[email protected]', os.getenv("EMAIL_PASSWORD"))

msg = MIMEText(message)
msg['Subject'] = 'SMS 테스트'
msg['To'] = '[email protected]'
smtp.sendmail('[email protected]', '[email protected]', 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()
client.publish(
PhoneNumber="+82"+target_number,
Message=message
)
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0c024b9

Please sign in to comment.