Guest User

Untitled

a guest
Jan 8th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.71 KB | None | 0 0
  1. 'use strict';
  2. const nodemailer = require('nodemailer');
  3.  
  4. // create reusable transporter object using the default SMTP transport
  5. let transporter = nodemailer.createTransport({
  6. host: 'localhost.com',
  7. port: 465,
  8. secure: true,
  9. auth: {
  10. user: 'user',
  11. pass: 'pass',
  12. }
  13. });
  14.  
  15. module.exports = (msg) => {
  16. let { from, to, subject, html } = msg;
  17. // setup email data with unicode symbols
  18. let mailOptions = {
  19. from,
  20. to,
  21. subject, // plain text body
  22. html,
  23. };
  24.  
  25. transporter.sendMail(mailOptions, (error, info) => {
  26. if (error) {
  27. return console.log(error);
  28. }
  29. console.log('Message %s sent: %s', info.messageId, info.response);
  30. });
  31. }
  32.  
  33. { Error: 139970611431232:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794:
  34. code: 'ECONNECTION', command: 'CONN' }
  35.  
  36. smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
  37. biff = no
  38. append_dot_mydomain = no
  39. readme_directory = no
  40.  
  41. smtpd_tls_cert_file=/etc/postfix/cert.pem
  42. smtpd_tls_key_file=/etc/postfix/privkey.pem
  43. smtpd_use_tls=yes
  44. smtpd_tls_session_cache_database =
  45. btree:${data_directory}/smtpd_scache
  46. smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
  47. # inbound
  48. smtpd_tls_security_level = may
  49. smtpd_tls_mandatory_protocols = !SSLv2 !SSLv3
  50. # outbound
  51. smtp_tls_security_level = may
  52. smtp_tls_mandatory_protocols = !SSLv2 !SSLv3
  53.  
  54. smtpd_relay_restrictions = permit_mynetworks permite_sasl_authenticated defer_unauth_destination
  55. myhostname = zacharyhill.xyz
  56. virtual_alias_maps = hash:/etc/postfix/virtual
  57. alias_database = hash:/etc/aliases
  58. myorigin = /etc/mailname
  59. mydestination = $myhostname, localhost, localhost.$mydomain, $mydomain
  60. relayhost =
  61. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0.0]/104 [::1]/128
  62. mailbox_command = procmail -a "$EXTENSION"
  63. mailbox_size_limit = 0
  64. recipient_delimiter = +
  65. inet_interfaces = loopback-only
  66. inter_protocols = all
  67.  
  68. #
  69. # Postfix master process configuration file. For details on the format
  70. # of the file, see the master(5) manual page (command: "man 5 master" or
  71. # on-line: http://www.postfix.org/master.5.html).
  72. #
  73. # Do not forget to execute "postfix reload" after editing this file.
  74. #
  75. # ==========================================================================
  76. # service type private unpriv chroot wakeup maxproc command + args
  77. # (yes) (yes) (no) (never) (100)
  78. # ==========================================================================
  79. smtp inet n - n - - smtpd
  80. #smtp inet n - y - 1 postscreen
  81. #smtpd pass - - y - - smtpd
  82. #dnsblog unix - - y - 0 dnsblog
  83. #tlsproxy unix - - y - 0 tlsproxy
  84. submission inet n - y - - smtpd
  85. -o syslog_name=postfix/submission
  86. -o smtpd_tls_security_level=encrypt
  87. -o smtpd_sasl_auth_enable=yes
  88. -o smtpd_reject_unlisted_recipient=no
  89. -o smtpd_client_restrictions=$mua_client_restrictions
  90. -o smtpd_helo_restrictions=$mua_helo_restrictions
  91. -o smtpd_sender_restrictions=$mua_sender_restrictions
  92. -o smtpd_recipient_restrictions=
  93. -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  94. -o milter_macro_daemon_name=ORIGINATING
  95. smtps inet n - y - - smtpd
  96. # -o syslog_name=postfix/smtps
  97. # -o smtpd_tls_wrappermode=yes
  98. # -o smtpd_sasl_auth_enable=yes
  99. # -o smtpd_reject_unlisted_recipient=no
  100. # -o smtpd_client_restrictions=$mua_client_restrictions
  101. # -o smtpd_helo_restrictions=$mua_helo_restrictions
  102. # -o smtpd_sender_restrictions=$mua_sender_restrictions
  103. # -o smtpd_recipient_restrictions=
  104. # -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  105. # -o milter_macro_daemon_name=ORIGINATING
  106. #628 inet n - y - - qmqpd
  107. pickup unix n - y 60 1 pickup
  108. cleanup unix n - y - 0 cleanup
  109. qmgr unix n - n 300 1 qmgr
  110. #qmgr unix n - n 300 1 oqmgr
  111. tlsmgr unix - - y 1000? 1 tlsmgr
  112. rewrite unix - - y - - trivial-rewrite
  113. bounce unix - - y - 0 bounce
  114. defer unix - - y - 0 bounce
  115. trace unix - - y - 0 bounce
  116. verify unix - - y - 1 verify
  117. flush unix n - y 1000? 0 flush
  118. proxymap unix - - n - - proxymap
  119. proxywrite unix - - n - 1 proxymap
  120. smtp unix - - y - - smtp
  121. relay unix - - y - - smtp
  122. # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
  123. showq unix n - y - - showq
  124. error unix - - y - - error
  125. retry unix - - y - - error
  126. discard unix - - y - - discard
  127. local unix - n n - - local
  128. virtual unix - n n - - virtual
  129. lmtp unix - - y - - lmtp
  130. anvil unix - - y - 1 anvil
  131. scache unix - - y - 1 scache
  132. #
  133. # ====================================================================
  134. # Interfaces to non-Postfix software. Be sure to examine the manual
  135. # pages of the non-Postfix software to find out what options it wants.
  136. #
  137. # Many of the following services use the Postfix pipe(8) delivery
  138. # agent. See the pipe(8) man page for information about ${recipient}
  139. # and other message envelope options.
  140. # ====================================================================
  141. #
  142. # maildrop. See the Postfix MAILDROP_README file for details.
  143. # Also specify in main.cf: maildrop_destination_recipient_limit=1
  144. #
  145. maildrop unix - n n - - pipe
  146. flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
  147. #
  148. # ====================================================================
  149. #
  150. # Recent Cyrus versions can use the existing "lmtp" master.cf entry.
  151. #
  152. # Specify in cyrus.conf:
  153. # lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
  154. #
  155. # Specify in main.cf one or more of the following:
  156. # mailbox_transport = lmtp:inet:localhost
  157. # virtual_transport = lmtp:inet:localhost
  158. #
  159. # ====================================================================
  160. #
  161. # Cyrus 2.1.5 (Amos Gouaux)
  162. # Also specify in main.cf: cyrus_destination_recipient_limit=1
  163. #
  164. #cyrus unix - n n - - pipe
  165. # user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
  166. #
  167. # ====================================================================
  168. # Old example of delivery via Cyrus.
  169. #
  170. #old-cyrus unix - n n - - pipe
  171. # flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
  172. #
  173. # ====================================================================
  174. #
  175. # See the Postfix UUCP_README file for configuration details.
  176. #
  177. uucp unix - n n - - pipe
  178. flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
  179. #
  180. # Other external delivery methods.
  181. #
  182. ifmail unix - n n - - pipe
  183. flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
  184. bsmtp unix - n n - - pipe
  185. flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
  186. scalemail-backend unix - n n - 2 pipe
  187. flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
  188. mailman unix - n n - - pipe
  189. flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  190. ${nexthop} ${user}
  191.  
  192. { Error: 139776600639296:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794:
  193. code: 'ECONNECTION', command: 'CONN' }
  194.  
  195. let transporter = nodemailer.createTransport({
  196. host: 'localhost.com',
  197. port: 465,
  198. -> secure: false,
  199. auth: {
  200. user: 'user',
  201. pass: 'pass',
  202. }
  203. });
  204.  
  205. const transporter = nodemailer.createTransport({
  206. port: 25,
  207. host: 'localhost',
  208. tls: {
  209. rejectUnauthorized: false
  210. },
  211. });
  212.  
  213. var message = {
  214. from: 'noreply@yourotherdomain.com',
  215. to: 'whatever@thisdomain.com',
  216. subject: 'Confirm Email',
  217. text: 'Please confirm your email',
  218. html: '<p>Please confirm your email</p>'
  219. };
  220.  
  221. transporter.sendMail(message, (error, info) => {
  222. if (error) {
  223. return console.log(error);
  224. }
  225. console.log('Message sent: %s', info.messageId);
  226. });
Add Comment
Please, Sign In to add comment