简体   繁体   English

将 email ( python smtp ) 发送到特定域(不是.Gmail)

[英]Send email ( python smtp ) to a specific domain (not .Gmail)

import smtplib
from smtplib import SMTP

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

msg = MIMEMultipart()  
msg['From'] = 'example1@gmail.com'
#Sender
msg['To'] = 'example2@uc.cl'
#Receiver

msg['Subject'] = 'python'
message = ' Wena mimo, como estai mimo'
msg.attach(MIMEText(message))

mailserver = smtplib.SMTP('smtp.gmail.com',587)
# identify ourselves to smtp gmail client
mailserver.ehlo()
# secure our email with tls encryption
mailserver.starttls()
# re-identify ourselves as an encrypted connection
mailserver.ehlo()
mailserver.login('example1@gmail.com', 'password')
#login to the account

mailserver.sendmail('example1@gmail.com','example2@uc.cl',msg.as_string())

mailserver.quit()

#I make a code that sends emails to differents mail(example @gmail and @corporative ) but i try to send mail to XXXXXXXX@uc.cl ( https://www.uc.cl ) but this mail dont receive the message #我制作了一个将电子邮件发送到不同邮件的代码(例如@gmail和@corporative),但我尝试将邮件发送到XXXXXXXX@uc.cl( https://www.uc.cl )但是这封邮件没有收到邮件

This is a code for Python3 in Ubuntu 18.04 I dont know if the problem is the port:587 or the domain uc.cl or the code, maybe the domain uc.cl takes a high level on this security THis domain its from a University这是 Ubuntu 18.04 中 Python3 的代码 我不知道问题是端口:587 还是域 uc.cl 或代码,也许域 uc.cl 在此安全性上具有较高的水平 这是来自大学的域

I assume the school mail server might try to block the mail coming from your python server.我假设学校邮件服务器可能会尝试阻止来自您的 python 服务器的邮件。

A few things you could try...你可以尝试几件事...

  • Sending the email while connected to the school wifi.在连接到学校 wifi 时发送 email。 Maybe they don't block internal traffic也许他们不会阻止内部流量
  • Try sending to a email server you set up just to check your code is working right尝试发送到您设置的 email 服务器,以检查您的代码是否正常工作
  • Make a new email account yahoo, etc and login with the code above and try sending to the other accounts you can test with.创建一个新的 email 帐户 yahoo 等并使用上面的代码登录并尝试发送到您可以测试的其他帐户。 This should give you a good idea what is occuring.这应该让您很好地了解正在发生的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM