import yamail
username = "xxxxxx@qq.com"
password = "xxxxxx"
host = "smtp.qq.com"
# host = "smtp.163.com" #163
# host = "smtp.126.com" #qq
# smtp.send(to="aaaaaa@qq.com")
smtp = yamail.SMTP(host=host,user=username,password=password)
smtp.send(to=["aaaaaaa@qq.com"],
cc=["ssssssss@qq.com"],
subject="你好呀",
contents="哈哈哈哈",
attachments="qq.xls")
import requests,time
import hmac
import hashlib
import base64
import urllib.parse
url = "https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
def get_sign():
timestamp = str(round(time.time() * 1000))
secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
secret_enc = secret.encode()
string_to_sign = '{}\n{}'.format(timestamp, secret)
string_to_sign_enc = string_to_sign.encode()
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
return timestamp,sign
for i in range(10):
data = {
"msgtype": "text",
"at": {
"atMobiles":["xxxxxxx"],
"atUserIds":["zxxxxx"],
"isAtAll":False
},
"text": {
"content": " 小yi,你看你多美!"
}
}
timestamp,sign = get_sign()
params = {"timestamp":timestamp,"sign":sign}
r = requests.post(url,json=data,params=params)
print(r.json())
time.sleep(1)