Skip to content

Instantly share code, notes, and snippets.

@israeleriston
Created April 13, 2018 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save israeleriston/f0d2eb0bc453bef9faab8d554c14a47c to your computer and use it in GitHub Desktop.
Save israeleriston/f0d2eb0bc453bef9faab8d554c14a47c to your computer and use it in GitHub Desktop.
Function cloud send e-mail using firebase
var user = event.data.val()
var { age, email, grade, name, phone, text, unit } = user
const destination = unit === 'Perdizes' ? 'debora.bueno@batistabrasileiro.com.br' : 'secretariageral@cbbauru.com.br'
const to = project === 'batista-webapp' ? destination : 'contato@guibarscevicius.com.br'
console.log('projeto:', project)
var data = {
from: 'no-reply@batistabrasileiro.com.br',
subject: `Contato através do site de ${name}`,
html: `<p>A seguinte mensagem de <b>${name}</b> foi enviada através do site:</p><br>
<p>Nome: ${name}</p>
<p>Email: ${email}</p>
<p>Telefone: ${phone}</p>
${grade ? '<p>Série: ' + grade + '</p>' : ''}
<p>Idade da criança: ${age}</p><br>
${text ? '<p>Mensagem: ' + text + '</p>' : ''}`,
to
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment