|
| 1 | +/** |
| 2 | + * Copyright 2017, Google, Inc. |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +'use strict'; |
| 17 | + |
| 18 | +// [START send] |
| 19 | +var mailer = require('nodemailer'); |
| 20 | +var smtp = require('nodemailer-smtp-transport'); |
| 21 | + |
| 22 | +var transport = mailer.createTransport( |
| 23 | + smtp({ |
| 24 | + host: 'in.mailjet.com', |
| 25 | + port: 2525, |
| 26 | + auth: { |
| 27 | + user: process.env.MAILJET_API_KEY || '<your-mailjet-api-key', |
| 28 | + pass: process.env.MAILJET_API_SECRET || '<your-mailjet-api-secret>', |
| 29 | + }, |
| 30 | + }) |
| 31 | +); |
| 32 | + |
| 33 | +transport.sendMail( |
| 34 | + { |
| 35 | + from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM', // From address |
| 36 | + to: '[email protected]', // To address |
| 37 | + subject: 'test email from Node.js on Google Cloud Platform', // Subject |
| 38 | + text: 'Hello!\n\nThis a test email from Node.js.', // Content |
| 39 | + }, |
| 40 | + function(err, json) { |
| 41 | + if (err) { |
| 42 | + console.log(err); |
| 43 | + } else { |
| 44 | + console.log(json); |
| 45 | + } |
| 46 | + } |
| 47 | +); |
| 48 | +// [END send] |
0 commit comments