title: How to send customize e-mail with Firebase cloud functions
body: <p>I want to send a mail once a user is created with a firebase cloud functions, using nodemail and postmark.</p>
  
  <p>I followed this tutorial : <a href="https://postmarkapp.com/blog/sending-transactional-emails-via-firebase-and-cloud-functions" rel="nofollow noreferrer">Tutorial link</a> from Dave Martin</p>
  
  <p><strong>But keep getting this error:</strong> </p>
  
  <blockquote>
    <p>There was an error while sending the welcome email: { <strong>status:</strong> 422, <strong>message:</strong> 'Zero recipients specified', <strong>code:</strong> 300 }</p>
  </blockquote>
  
  <p><strong>Here is my code to send a mail from cloud functions:</strong></p>
  
  <pre><code>//Mail 
  const nodemailer = require('nodemailer')
  const postmarkTransport = require('nodemailer-postmark-transport')
  
  
  // Google Cloud environment variable used:
  // firebase functions:config:set postmark.key="API-KEY-HERE"
  const postmarkKey = functions.config().postmark.key
  const mailTransport = nodemailer.createTransport(postmarkTransport({
  auth: {
      apiKey: postmarkKey
  }
  }))
  exports.OnUserCreation = functions.auth.user().onCreate((user) =&gt; 
  {
  console.log("user created: " + user.data.uid);
  console.log("user email: " + user.data.email);
  sendEmail(user);
  })
  
  function sendEmail(user) 
  {
  // Send welcome email to new users
  const mailOptions = 
  {
      from: '"test" &lt;test@test.com&gt;',
      to: user.email,
      subject: 'Welcome!',
      html: 'hello'
  }
  // Process the sending of this email via nodemailer
  return mailTransport.sendMail(mailOptions)
      .then(() =&gt; console.log('Welcome confirmation email sent'))
      .catch((error) =&gt; console.error('There was an error while sending the welcome email:', error))
  }
  </code></pre>
  
  <p>My postmark.key is already setup in the firebase config... The API tell me the problem is the format I use to send the mail informations.. How could I fix it ?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I also tried to modify the mailOptions as follow and still the same error:</p>
  
  <pre><code>    const mailOptions = {
          from: 'test@test.com',
          to: user.email,
          subject: 'Welcome!',
          textBody: 'hello'
      }
  </code></pre>