我使用NodeMailer创建了以下功能,它似乎在没有问题的情况下发送电子邮件(收到控制台和电子邮件中的"消息发送"通知),除了没有发送任何电子邮件的附件!
尝试了一堆电子邮件地址(gmail,谷歌应用程序,hotmail),但所有人都在做同样的事情.请帮忙!
var sendWithAttachment = function(userMail, subject, html, attachment_path, cb){
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "labs@domain.com",
pass: "password"
}
});
var mailOptions = {
from: "Labs <labs@domain.com>",
to: userMail,
subject: subject || "[blank]"
html: html || "[none]"
generateTextFromHTML: true,
attachments: [
{ // filename and content type is derived from path
path: attachment_path
},
{ // utf-8 string as an attachment
filename: 'check.txt',
content: 'checking that some attachments work...'
},
],
};
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){ …Run Code Online (Sandbox Code Playgroud) 我确定我做的很简单,但似乎无法找到解释.我的模板中有以下行,它不会向html输出打印任何值:
<%= _.each(@place.get("hash"),(count, tag) -> "#{tag} ") %>
Run Code Online (Sandbox Code Playgroud)
这行是完美地打印到控制台的值:
<%= _.each(@place.get("hash"),(count, tag) -> console.log "#{tag} ") %>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用打印命令并刷新时,谷歌浏览器会抛出一个打印菜单.我该如何解决这个问题
我的情况与此代码相当:
i=0
def add_one(i)
i+=1
puts "FUNCTION:#{i}"
end
begin
puts "BEGIN:#{i}"
raise unless i>5
rescue
add_one(i)
puts "RESCUE:#{i}"
retry
end
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我反复看到这个输出:
BEGIN:0
FUNCTION:1
RESCUE:0
Run Code Online (Sandbox Code Playgroud)
此版本i完美地增加并完成程序:
i=0
begin
puts "BEGIN:#{i}"
raise unless i>5
rescue
i+=1
puts "RESCUE:#{i}"
retry
end
Run Code Online (Sandbox Code Playgroud)
为什么会有区别?如何在rescue块中获取函数来实际修改变量?