title: Firebase functions environment variables can not read property of undefined
body: <p>i have an angular app thats connected with firebase. So far i've got the db and authentication working. But right now i'm stuck on cloud functions.
  I'm trying to send an email with nodemailer every time a person makes a reservation for a benefiet. 
  The function code is mostly copied from firebase github functions examples
  like this:</p>
  
  <pre><code>'use strict';
  
  const functions = require('firebase-functions');
  const nodemailer = require('nodemailer');
  // Configure the email transport using the default SMTP transport and a GMail account.
  // For other types of transports such as Sendgrid see https://nodemailer.com/transports/
  // TODO: Configure the `gmail.email` and `gmail.password` Google Cloud environment variables.
  const gmailEmail = functions.config().gmail.email;
  const gmailPassword = functions.config().gmail.password;
  const mailTransport = nodemailer.createTransport({
    service: 'gmail',
    auth: {
      user: gmailEmail,
      pass: gmailPassword,
    },
  });
  
  // Sends an email confirmation when a user changes his mailing list subscription.
  exports.sendEmailConfirmation = functions.database.ref('/users/{uid}').onWrite(async (change) =&gt; {
    const snapshot = change.after;
    const val = snapshot.val();
  
    if (!snapshot.changed('subscribedToMailingList')) {
      return null;
    }
  
    const mailOptions = {
      from: '"Spammy Corp." &lt;noreply@firebase.com&gt;',
      to: val.email,
    };
  
    const subscribed = val.subscribedToMailingList;
  
    // Building Email message.
    mailOptions.subject = subscribed ? 'Thanks and Welcome!' : 'Sad to see you go :`(';
    mailOptions.text = subscribed ?
        'Thanks you for subscribing to our newsletter. You will receive our next weekly newsletter.' :
        'I hereby confirm that I will stop sending you the newsletter.';
  
    try {
      await mailTransport.sendMail(mailOptions);
      console.log(`New ${subscribed ? '' : 'un'}subscription confirmation email sent to:`, val.email);
    } catch(error) {
      console.error('There was an error while sending the email:', error);
    }
    return null;
  });
  </code></pre>
  
  <p>After this i set my environment variable like this:</p>
  
  <pre><code>firebase functions:config:set gmail.email="myusername@gmail.com" gmail.password="secretpassword"
  </code></pre>
  
  <p>i deploy my function to firebase when using firebase serve i get an error:
  -TypeError: Cannot read property 'email' of undefined</p>
  
  <p>when i check with firebase functions:config:get it shows me the correct data
  The webapp itself is not deployed yet (could this be it?)</p>
  
  <p>Any ideas/help would be appreciated
  thx</p>