下面是自动化助手的命令。
wget -O openvpn.sh https://get.vpnsetup.net/ovpn
sudo bash openvpn.sh --auto
cat <<EOF > send_email.py
import smtplib
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_email_with_attachment(subject, body, to_email, file_path):
# 基本设置
smtp_server = 'smtp.163.com'
smtp_port = 994
from_email = 'SMTP邮箱账号'
password = '登录密码,如果是163或gmail需要应用程序专用密码' # 替换密码
# 创建一个MIMEMultipart对象
msg = MIMEMultipart()
msg['From'] = from_email
msg['To'] = to_email
msg['Subject'] = subject
# 添加正文到邮件
msg.attach(MIMEText(body, 'plain'))
# 附件处理
with open(file_path, 'rb') as attachment:
part = MIMEBase('application', 'octet-stream')
part.set_payload(attachment.read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', f'attachment; filename={file_path.split("/")[-1]}')
msg.attach(part)
# 连接到SMTP服务器并发送邮件
server = smtplib.SMTP_SSL(smtp_server)
server.connect(smtp_server, smtp_port)
server.login(from_email, password)
server.sendmail(from_email, to_email, msg.as_string())
server.quit()
# 使用
send_email_with_attachment(
'件名',
'正文',
'收件人邮箱地址',
'/home/ubuntu/client.ovpn'
)
EOF
python3 send_email.py