I have a php script to fetch user email address from my wordpress site database. The php script as follow
$sql = "SELECT user_email FROM wp_users";
$addr = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_assoc($addr)){
printf ("%s\n", $row["user_email"]);
}
The output will look like this
abcd@gmail.com
ggyy@gmail.com
In my python code i use urllib2
to read the php and the python snippet look like this
response = urllib2.urlopen('http://192.168.0.168/useremail.php')
status = response.read()
fromaddr = "testing123@gmail.com"
toaddr = status
server.sendmail(fromaddr, toaddr)
In this case, the email always sent to the first email address only despite there are several email address retrieve from the php script. Please help me to solve this problem. Sorry to say that I am a beginner in programming.
答案 0 :(得分:1)
waitUntilFinished
需要一个邮件地址列表。因此,您需要使用urllib2的响应构建该列表。
使用splitlines()
返回字符串中的行列表。
即。 :
sendmail()
希望它有所帮助。