我正在尝试使用nodemailer从我的应用程序发送电子邮件.
我的设置如下:
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = nodemailer.createTransport(smtpTransport ({
host: 'smtp.companyname.dk',
secureConnection: true,
port: 587,
auth: {
user: 'support@companyname.dk',
pass: '****'
}
}));
var mailOptions = {
from: 'Olaf <ob@companyname.dk>',
to: 'john@test.dk',
subject: 'This is a test ',
text: 'Hello world ',
html: '<b>Hello world </b>'
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
}
});
Run Code Online (Sandbox Code Playgroud)
运行此后,它给我以下错误:
{ [Error: Hostname/IP doesn't match certificate's altnames: "Host: smtp.companyname.dk. is not in the …
Run Code Online (Sandbox Code Playgroud) 我正在我正在进行的项目中使用angular-chartJS,并且我需要为条形图中的每个条形图使用不同的颜色.
帆布:
<canvas id="bar" class="chart chart-bar" data="medal_data" labels="medal_ticks"></canvas>
Run Code Online (Sandbox Code Playgroud)
控制器:
$scope.medal_ticks = ['Gold', 'Silver', 'Bronze', 'Not passed'];
$scope.series = ['Medaljer'];
$scope.medals_colours= ['#087D76', '#B3BC3A', '#38B665', '#8B4A9D'];
$scope.medal_data = ['1', '5', '2', '0'];
Run Code Online (Sandbox Code Playgroud)
我试图将属性添加colours="medals_colours"
到我的画布,唯一的问题是它只使用数组中的第一种颜色,我想要的是每种颜色代表每一列.所以,#087D76
用于表示Gold
,#B3BC3A
对Silver
等
我最近创建了一个网页使用Angularjs
,我正在尝试使用Google将其编入索引pushstate
.
我已经做了相当的研究和升技发现,我可以用Googlebot-simulater
在Google Webmaster tools
模仿我的网站上谷歌访,看机器人是怎么看我的网页VS什么用户看到.
在这里,结果看起来不错,Google
看到一模一样的东西,我的用户,并且所有页面/子页面获得的任何状态partially
或fully
.
我今天早上被告知的另一种方式Google
是,通过Google搜索来查看我网站上看到的内容site:domainname
.这里谈到的所有页面/子页面的列表,Google
具有cached
和通过点击不同的链接,你会得到其中相应的页面显示的视图.
这是我有点担心我错过了什么,因为无论我的页面是什么partially
/ fully
状态Goolgebot-simulation
,当我查看我的页面(使用第二种方法)时,页面都是空白的.
这是我第一次索引网页,我已经尝试了几天,但没有任何运气.是否有人能说出我做错了什么/错过了什么,或者至少指出了正确的方向?或者我应该多一点耐心?
在我的应用程序中,当用户通过测试时,将自动生成一个文凭(pdf
).我通过使用html-pdf
node-module
它来完成,它检索html文件并使其成为pdf.
var fs = require('fs'),
pdf = require('html-pdf'),
path = require('path'),
ejs = require('ejs');
var html = fs.readFileSync('./phantomScripts/certificate.html', 'utf8');
var options = { filename: 'businesscard.pdf', format: 'A4', orientation: 'portrait', directory: './phantomScripts/',type: "pdf" };
pdf.create(html, options).toFile(function(err, res) {
if (err) return console.log(err);
console.log(res);
});
Run Code Online (Sandbox Code Playgroud)
这种转换,从html
到pdf
,完美的作品,看起来真的很不错.现在我想要的是使template
动态变得更加动态,这意味着根据用户的不同,他们的名字会出现在pdf
.
我曾经工作过ejs
生成一个电子邮件模板,所以我认为我的问题可以用这个来解决,但如上所述,我没有那么多工作,ejs
也无法弄清楚如何发送data
到我的ejs
文件?
我正在使用node-html-pdf模块从ejs
我创建的模板生成PDF文件,该模板在生成后会保存在我的服务器上。
现在这可以正常工作,但是我真正需要的是单击按钮时,它会生成PDF并下载文件,而不是保存文件。
在下面,您可以看到我生成和保存文件的代码:
var html = null;
ejs.renderFile('./templates/participants.ejs', {users: req.body.users, course: req.body.course, organization: req.body.organization}, function (err, result) {
if (result) {
html = result;
}
else {
res.end('An error occurred');
console.log(err);
}
});
pdf.create(html).toStream(function(err, stream){
var file = 'c:' + stream.path;
// var file = full path to tmp file (added 'c:' because I'm testing locally right now)
res.setHeader('Content-type', 'application/pdf');
res.setHeader('Content-disposition', 'attachment; filename=' + file);
res.download(file, req.body.course.name + '.pdf', function(err){
if (err) {
// Handle error, …
Run Code Online (Sandbox Code Playgroud) javascript ×5
node.js ×3
angularjs ×2
bar-chart ×1
chart.js ×1
ejs ×1
email ×1
indexing ×1
nodemailer ×1
pdf ×1
web-crawler ×1