auch diese scheiße funktioniert jetzt, allerdings richtig unsauber weil ich kein bock mehr habe:
var express = require('express');
var app = express();
var path = require('path');
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.get('/hello', function (req, res) {
res.send('Hello World!');
});
app.post('/test', function (req, res) {
console.log('works');
var nodemailer = require('nodemailer');
var transporterObjectConfig = nodemailer.createTransport({
host: 'hostname',
port: '587',
secure: false,
requireTLS: true,
auth: {
user: 'username',
pass: 'password'
}
});
// setup e-mail data with unicode symbols
var mailOptions = {
from: 'sender address', // sender address
to: 'recipient', // list of receivers
subject: 'Hello', // Subject line
text: 'Hello world ?', // plaintext body
html: '<b>Hello world ?</b>' // html body
};
// send mail with defined transport object
transporterObjectConfig.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
und html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sample Site</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style>
body { padding-top:50px; }
</style>
</head>
<body>
<input name="like" id="like" value="Like" type="submit" />
<div class="container">
<div class="jumbotron">
<h1>res.sendFile() Works!</h1>
</div>
</div>
<script>
$('#like').click(function(){
$.post('/test');
});
</script>
</body>
</html>
jetzt bau ich email und username eingabe. im anschluss zerbrech ich mir den kopf über aktivierungslink