@@ -68,13 +68,6 @@ async def send_email(
6868 """
6969 # 动态配置
7070 dynamic_email_config = None
71- _email_type_key = 'EMAIL'
72- _email_status_key = 'EMAIL_STATUS'
73- _email_host_key = 'EMAIL_HOST'
74- _email_port_key = 'EMAIL_PORT'
75- _email_ssl_key = 'EMAIL_SSL'
76- _email_username_key = 'EMAIL_USERNAME'
77- _email_password_key = 'EMAIL_PASSWORD'
7871
7972 # 检查 config 插件配置
8073 def get_config_table (conn ):
@@ -85,24 +78,24 @@ def get_config_table(conn):
8578 exists = await coon .run_sync (get_config_table )
8679
8780 if exists :
88- dynamic_email_config = await config_dao .get_all (db , _email_type_key )
81+ dynamic_email_config = await config_dao .get_by_type (db , 'email' )
8982
9083 try :
9184 # 动态配置发送
9285 if dynamic_email_config :
9386 configs = {d ['key' ]: d for d in select_list_serialize (dynamic_email_config )}
94- if configs .get (_email_status_key ):
87+ if configs .get ('EMAIL_STATUS' ):
9588 if len (dynamic_email_config ) < 6 :
9689 raise errors .NotFoundError (msg = '缺少邮件动态配置,请检查系统参数配置-邮件配置' )
9790 smtp_client = SMTP (
98- hostname = configs .get (_email_host_key ),
99- port = configs .get (_email_port_key ),
100- use_tls = configs .get (_email_ssl_key ) == '1' ,
91+ hostname = configs .get ('EMAIL_HOST' ),
92+ port = configs .get ('EMAIL_PORT' ),
93+ use_tls = configs .get ('EMAIL_SSL' ) == '1' ,
10194 )
102- message = await render_message (subject , configs .get (_email_username_key ), content , template ) # type: ignore
95+ message = await render_message (subject , configs .get ('EMAIL_USERNAME' ), content , template ) # type: ignore
10396 async with smtp_client :
104- await smtp_client .login (configs .get (_email_username_key ), configs .get (_email_password_key )) # type: ignore
105- await smtp_client .sendmail (configs .get (_email_username_key ), recipients , message ) # type: ignore
97+ await smtp_client .login (configs .get ('EMAIL_USERNAME' ), configs .get ('EMAIL_PASSWORD' )) # type: ignore
98+ await smtp_client .sendmail (configs .get ('EMAIL_USERNAME' ), recipients , message ) # type: ignore
10699
107100 # 本地配置发送
108101 message = await render_message (subject , settings .EMAIL_USERNAME , content , template )
0 commit comments