Python 您如何删除“;[附件已删除]“;字符串作为sms发送?

Python 您如何删除“;[附件已删除]“;字符串作为sms发送?,python,python-3.x,mime,smtplib,Python,Python 3.x,Mime,Smtplib,我发现了一个小程序,可以通过我的gmail向我的手机发送短信,但当我发送短信时,它会添加“[附件已删除]”,有没有办法删除 import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart email = "Your Email" pas = "Your Pass" sms_gateway = 'number@tmomail.net' # The server

我发现了一个小程序,可以通过我的gmail向我的手机发送短信,但当我发送短信时,它会添加“[附件已删除]”,有没有办法删除

import smtplib 
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

email = "Your Email"
pas = "Your Pass"

sms_gateway = 'number@tmomail.net'
# The server we use to send emails in our case it will be gmail but every email provider has a different smtp 
# and port is also provided by the email provider.
smtp = "smtp.gmail.com" 
port = 587
# This will start our email server
server = smtplib.SMTP(smtp,port)
# Starting the server
server.starttls()
# Now we need to login
server.login(email,pas)

# Now we use the MIME module to structure our message.
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = sms_gateway
# Make sure you add a new line in the subject
msg['Subject'] = "You can insert anything\n"
# Make sure you also add new lines to your body
body = "You can insert message here\n"
# and then attach that body furthermore you can also send html content.
msg.attach(MIMEText(body, 'plain'))

sms = msg.as_string()

server.sendmail(email,sms_gateway,sms)

# lastly quit the server
server.quit()

在执行server.sendmail步骤时,只需发送正文字符串。因此,应该是:

import smtplib 

email = "Your Email"
pas = "Your Pass"

sms_gateway = 'number@tmomail.net'
smtp = "smtp.gmail.com" 
port = 587
# This will start our email server
server = smtplib.SMTP(smtp,port)
# Starting the server
server.starttls()
# Now we need to login
server.login(email,pas)

body = "Yo, im done."

server.sendmail(email,sms_gateway,body)

# lastly quit the server
server.quit()

在执行server.sendmail步骤时,只需发送正文字符串。因此,应该是:

import smtplib 

email = "Your Email"
pas = "Your Pass"

sms_gateway = 'number@tmomail.net'
smtp = "smtp.gmail.com" 
port = 587
# This will start our email server
server = smtplib.SMTP(smtp,port)
# Starting the server
server.starttls()
# Now we need to login
server.login(email,pas)

body = "Yo, im done."

server.sendmail(email,sms_gateway,body)

# lastly quit the server
server.quit()

我猜这是GMail添加的,而不是任何Python模块添加的。1.这实际上是先给你发电子邮件吗?2.我如何复制它的sms部分?我没有收到电子邮件或短信,登录gmail成功,成功执行后我收到以下消息:进程结束,退出代码为0。它使用我的gmail向手机发送消息。要为您自己的手机复制短信,您需要短信yourphonenumber@whatevergatewayyouneedforyourcarrier我猜这是GMail添加的,而不是任何Python模块添加的。1.这实际上是先给你发电子邮件吗?2.我如何复制它的sms部分?我没有收到电子邮件或短信,登录gmail成功,成功执行后我收到以下消息:进程结束,退出代码为0。它使用我的gmail向手机发送消息。要为您自己的手机复制短信,您需要短信yourphonenumber@whatevergatewayyouneedforyourcarrier'