title: Send email when user is created on firestore using Cloud Functions
body: <p>I'm trying to send the email verification link after the user is created on my flutter app, but the email isn't sent and in my Cloud Functions Log I'm receiving the message when I deploy:</p>
  
  <blockquote>
    <p>{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":9,"message":"FAILED_PRECONDITION"},"authenticationInfo":{"principalEmail":"*************"},"requestMetadata":{"callerIp":"186.216.140.62","callerSuppliedUserAgent":"FirebaseCLI/6.5.0,gzip(gfe),gzip(gfe)","requestAttributes":{"time":"2019-03-29T23:21:10.130Z","auth":{}},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","authorizationInfo":[{"permission":"cloudfunctions.functions.update","granted":true,"resourceAttributes":{}},{"resource":"projects/pppppp-9800a/locations/us-central1/functions/sendVerificationEmail","permission":"cloudfunctions.functions.update","granted":true,"resourceAttributes":{}}],"resourceName":"projects/pppppp-9800a/locations/us-central1/functions/sendVerificationEmail","request":{"@type":"type.googleapis.com/google.cloud.functions.v1.UpdateFunctionRequest","function":{"labels":{"deployment-tool":"cli-firebase"},"eventTrigger":{"eventType":"providers/cloud.firestore/eventTypes/document.create","resource":"projects/pppppp-9800a/databases/(default)/documents/users/{userId}","service":"firestore.googleapis.com"},"sourceUploadUrl":"<a href="https://storage.googleapis.com/gcf-upload-us-central1-dc1829cf-3a07-4951-be81-1a15f892ed8d/8ea3f162-c860-4846-9064-04a855efca2f.zip?GoogleAccessId=service-73683634264@gcf-admin-robot.iam.gserviceaccount.com&amp;Expires=1553903464&amp;Signature=" rel="nofollow noreferrer">https://storage.googleapis.com/gcf-upload-us-central1-dc1829cf-3a07-4951-be81-1a15f892ed8d/8ea3f162-c860-4846-9064-04a855efca2f.zip?GoogleAccessId=service-73683634264@gcf-admin-robot.iam.gserviceaccount.com&amp;Expires=1553903464&amp;Signature=</a>******************","name":"projects/pppppp-9800a/locations/us-central1/functions/sendVerificationEmail"}}}</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre><code>exports.sendVerificationEmail = functions.firestore.document('users/{userId}').onCreate((snap, context) =&gt; {
    const user = snap.data();
    console.log("----------------------");
    console.log("user created: " + user.uidColumn);
    admin.auth().generateEmailVerificationLink(user.email).then((link) =&gt; {
      console.log("**********" + link);
      sendVerificationEmail(user.emailColumn, link);
      return 0;
    }).catch(e =&gt; {
      console.log(e);
    })
    return 0;
  });
  
  function sendVerificationEmail(email, link) {
    var smtpConfig = {
      host: 'smtp.gmail.com',
      port: 465,
      secure: true, // use SSL
      auth: {
        user: 'myappemail@gmail.com',
        pass: 'password'
      }
    };
  
    var transporter = nodemailer.createTransport(smtpConfig);
  
    var mailOptions = {
      from: "qeaapp@gmail.com", // sender address
      to: email, // list of receivers
      subject: "Email verification", // Subject line
      text: "Email verification, press here to verify your email: " + link,
      html: "&lt;b&gt;Hello there,&lt;br&gt; click &lt;a href=" + link + "&gt; here to verify&lt;/a&gt;&lt;/b&gt;" // html body
    };
  
    transporter.sendMail(mailOptions, function (error, response) {
  
      if (error) {
        console.log(error);
      } else {
        console.log("Message sent: " + response.message);
      }
      return 0;
    });
    return 0;
  }
  </code></pre>
  
  <p>When I the the command <code>firebase deploy</code> I get the message <em>functions: failed to update function sendVerificationEmail
  HTTP Error: 400, Change of function trigger type or event provider is not allowed</em></p>
  
  <p>I'm new in JS and I don't know what these erros mean</p>