Python 电子邮件可以发送到我的电子邮件地址,但不能发送到其他地址?
我写了一个小脚本,检查本地网站上的房地产清单,并对照数据库中存储的清单检查新的清单。然后通过电子邮件发送任何新列表Python 电子邮件可以发送到我的电子邮件地址,但不能发送到其他地址?,python,email,selenium-webdriver,Python,Email,Selenium Webdriver,我写了一个小脚本,检查本地网站上的房地产清单,并对照数据库中存储的清单检查新的清单。然后通过电子邮件发送任何新列表 import pymongo from selenium import webdriver import smtplib import sys import json from pymongo import MongoClient client = MongoClient('localhost', 27017) db = client.properties collection
import pymongo
from selenium import webdriver
import smtplib
import sys
import json
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.properties
collection = db['capitalpacific']
#hold old properties imported from DB
oldProperties = []
#holds new properties gathered from page
newProperties = []
driver = webdriver.Firefox()
driver.get("http://cp.capitalpacific.com/Properties")
for property in driver.find_elements_by_css_selector('table.property div.property'):
title = property.find_element_by_css_selector('div.title h2')
location = property.find_element_by_css_selector('div.title h4')
marketing_package = property.find_element_by_partial_link_text('Marketing Package')
contact_email = property.find_element_by_partial_link_text('.com')
newProperties.append({
'title': title.text,
'location': location.text,
'marketing_package_url': marketing_package.get_attribute("href"),
'contact': contact_email.get_attribute("href")
})
driver.close()
'''if database not empty, add the old properties,
then compare against the newly fetched and remove repeats'''
if collection.count() != 0:
for post in collection.find():
oldProperties.append(post)
for oldListing in oldProperties:
for newListing in newProperties:
if oldListing['marketing_package_url'] == newListing['marketing_package_url']:
newProperties.remove(newListing)
'''if no new listings, exit the program. Otherwise, email all new
listings and then insert them into the DB'''
if len(newProperties) == 0:
sys.exit()
else:
fromaddr = 'myEmail@gmail.com'
toaddrs = ['myOtherEmail@gmail.com']
username = 'myEmail@gmail.com'
password = 'xxxxxxxxx'
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username, password)
for item in newProperties:
fullMessage = "New Listing @ Capital Pacific: " + "\n"
fullMessage += "Title: " + str(item['title']) + "\n"
fullMessage += "Location: " + str(item['location']) + "\n"
fullMessage += "Contact Email: " + str(item['contact']) + "\n"
server.sendmail(fromaddr, toaddrs, fullMessage)
collection.insert(item)
server.quit()
事情是这样的:它工作得很好,可以将任何新的电子邮件发送到我的电子邮件。但是,当我替换我的第二个电子邮件地址时(myOtherEmail@gmail.com在上面的例子中)和我的堂兄(他生活在不同的州)一起,他声称得到的是空消息,而不是包含数据的消息(我得到的是数据)
这可能是什么原因造成的?请友好一点,这是我用Python开始的第一个项目之一。为了澄清,他正在接收电子邮件,只是空白的(我在我的第二个(gmail)帐户上获得了完整的数据,他也有一个gmail帐户)。你有没有看一下你发送的邮件,确认它也是空白的?@Calum如果我检查我的主电子邮件发送文件夹,它们会显示为电子邮件发送给我的第二个,但是空白。然而,当我登录secondary时,它们会显示在电子邮件中的数据中。非常混乱。