-
Notifications
You must be signed in to change notification settings - Fork 0
/
socks-proxy.js
47 lines (38 loc) · 1.14 KB
/
socks-proxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* eslint no-console: 0 */
'use strict';
/*
This example demonstrates how to use a socks4/5 proxy
*/
// create SOCKS5 proxy with
// ssh -N -D 0.0.0.0:1080 username@remote.host
var nodemailer = require('../../lib');
// Create a SMTP transporter object
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'test.nodemailer@gmail.com',
pass: 'Nodemailer123'
},
logger: true, // log to console
debug: true, // include SMTP traffic in the logs
// define proxy configuration
proxy: 'socks5://localhost:1080/'
});
console.log('SMTP Configured');
var message = {
from: 'Sender Name <sender@example.com>',
to: '"Receiver Name" <receiver@example.com>',
subject: 'Nodemailer is unicode friendly ✔', //
text: 'Hello to myself!',
html: '<p><b>Hello</b> world!</p>'
};
console.log('Sending Mail');
transporter.sendMail(message, function (error, info) {
if (error) {
console.log('Error occurred');
console.log(error.message);
return;
}
console.log('Message sent successfully!');
console.log('Server responded with "%s"', info.response);
});