我正在尝试从var drop_boxes = $('.drop-box');
var area_grid = [];
var image_width = $('.img-class')[0].naturalWidth;
var image_height = $('.img-class')[0].naturalHeight;
drop_boxes.each(function() {
var position = $(this).position();
var width = $(this).width();
var height = $(this).height();
var positions_clone = positions.slice(0);
//console.log(positions_clone.length);
var top_offset = parseInt((position['top'] * image_width)/img_width);
var left_offset = parseInt((position['left'] * image_height)/img_height);
position['top'] = top_offset;
position['left'] = left_offset;
var width_offset = parseInt((width * image_width)/img_width);
var height_offset = parseInt((height * image_height)/img_height);
var width_counter = 0;
var height_counter = 0;
var area = width_offset * height_offset;
console.log(position);
console.log(width_offset);
console.log(height_offset);
if (position['top'] < image_height-1 && position['left'] < image_width) {
for (counter = 0; counter < area; counter++) {
var pos = [parseInt(position['left']+width_counter), parseInt(position['top']+height_counter)];
var index = positions.findIndex(function(item) {
// return result of comparing `data` with `item`
// This simple implementation assumes that all `item`s will be Arrays.
return pos.length === item.length && item.every(function(n, i) { return n === pos[i] });
});
//console.log(pos);
if (index > -1) {
positions_clone.splice(index, 1);
}
//area_grid.push(pos);
if (width_counter == width_offset) {
width_counter = 0;
height_counter += 1;
}
if (counter%100 == 0) {
var percentage = Math.round((counter/area)*100, 2);
console.log("Percentage: "+percentage+"%" + " "+counter);
}
width_counter += 1;
}
console.log(positions_clone.length);
console.log(area_grid.length);
areas[area_counter] = {'area': area_grid, 'positions': positions_clone};
parent.find('.area').text(area_counter);
area_counter += 1;
}
发送消息。我正在使用此命令localhost:1025
运行SMTP调试服务器。
以下是用于发送邮件的代码:
python -m smtpd -n localhost:1025
msg = mailer.Message(From='noreply@'+company['host'],
To=req['mail'],
Subject='E-mail confirmation',
Body=Template(open('./confirmation.html').read()).render(company=company, account=account, accode=accode))
mailer.Mailer(company['host'], port=1025).send(msg)
包含我的电子邮件地址,当我查看我的电子邮件收件箱和垃圾邮件文件夹时,我没有找到任何消息 - 据说是什么导致了这个问题?
答案 0 :(得分:3)
非常清楚in the documentation调试服务器不会尝试传递电子邮件。这是为了允许在不实际发送任何邮件的情况下测试和验证电子邮件的内容。
答案 1 :(得分:0)
我认为使用smtpd / mailer是一个错误。我用这种方法解决了这个问题:
使用以下方法测试Exim:
nano testexim
From: "Exim" <noreply@localhost>
To: MYFULLNAME MYEMAILADDRESS
Reply-To: noreply@localhost
Subject: Hello exim!
Content-Type: text/plain; charset=utf-8
this is exim test message
EOF
sendmail MYEMAILADDRESS&lt; testexim
结果:消息通过exim成功发送(sendmail命令)
李>
使用以下方法测试smtpd:
蟒
import smtplib
Import email.utils
from email.mime.text import MIMEText
# Create the message
msg = MIMEText('Hello SMTPD!')
msg['To'] = email.utils.formataddr((MYFULLNAME,
MYEMAILADDRESS))
msg['From'] = email.utils.formataddr(('SMTPD',
'noreply@localhost'))
msg['Subject'] = 'SMTPD test message'
server = smtplib.SMTP('localhost', 1025)
server.set_debuglevel(True) # show communication with the server
try:
server.sendmail('noreply@localhost',
[MYEMAILADDRESSS],
msg.as_string())
finally:
server.quit()
结果:通过smtpd发送消息失败
李>
尝试了一种不基于smtpd的方法:
蟒
from email.mime.text import MIMEText
from subprocess import Popen, PIPE
msg = MIMEText("Hello from exim")
msg["From"] = "noreply@localhost"
msg["To"] = MYEMAILADDRESS
msg["Subject"] = "Python sendmail test"
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
p.communicate(msg.as_string())
结果:以编程方式创建sendmail进程完成了这项工作