Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Uzantının yapılandırılması sırasında bir "Şablon koleksiyonu" parametresi belirttiyseniz e-postalarınız için Handlebars şablonları oluşturup yönetebilirsiniz.
Şablon koleksiyonu yapısı
Her dokümana, şablon koleksiyonunuza yazdığınız dokümanlarda şablon adı olarak kullanacağınız akılda kalıcı bir kimlik verin.
Şablon belgesi aşağıdaki alanlardan herhangi birini içerebilir:
subject: E-postanın konusu için bir şablon dizesi.
text: E-postanın düz metin içeriği için şablon dizesi.
html: E-postanın HTML içeriği için bir şablon dizesi.
amp: E-postanın AMP4EMAIL içeriği için bir şablon dizesi.
attachments: Değer olarak şablon dizeleri içeren ekler dizisi; Nodemailer seçenekleri desteklenir: utf-8 dizesi, özel içerik türü, URL, kodlanmış dize, veri URI'si ve önceden oluşturulmuş MIME düğümü (e-postanızın bulut sunucusunun dosya sistemine erişimi olmadığını unutmayın).
Örnek bir şablonun kimliği following ve içeriği şu şekilde olabilir:
{subject:"@{{username}} is now following you!",html:"Just writing to let you know that <code>@{{username}}</code> ({{name}}) is now following you.",attachments:[{filename:"{{username}}.jpg",path:"{{imagePath}}"}]}
Şablonları kullanarak e-posta gönderme
E-postaları şablon kullanarak yayınlamak için posta koleksiyonunuza belge eklerken template ve data özelliklerini içeren bir name alanı ekleyin. Örneğin, yukarıdaki following şablonumuzu kullanarak:
Şablon belgesinde {partial: true} belirterek yeniden kullanılabilir parçalar kullanarak şablonlar oluşturabilirsiniz. Standart veri alanlarının (subject, html, text ve amp) her biri yalnızca kendi ortamında kullanılan kısmi olarak tanımlanır. Örneğin, footer adlı bir kısmi şablonda şu gibi veriler olabilir:
{partial:true,html:"<p>This mail was sent by ExampleApp, Inc. <a href='https://example.com/unsubscribe'>Unsubscribe</a></p>",text:"This mail was sent by ExampleApp, Inc. Unsubscribe here: https://example.com/unsubscribe"}
Başka bir şablonda, adını (belge kimliği) referans vererek kısmi şablonu ekleyin:
<p>This is my main template content, but it will use a common footer.</p>
{{> footer }}
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-09-06 UTC."],[],[],null,["\u003cbr /\u003e\n\nIf you specified a \"Templates collection\" parameter during configuration of the\nextension, you can create and manage [Handlebars templates](https://handlebarsjs.com/)\ntemplates for your emails.\n\nTemplate collection structure\n\nGive each document a memorable ID that you use as the *template name* in the\ndocuments you write to your templates collection.\n\nThe template document can include any of the following fields:\n\n- **subject:** A template string for the subject of the email.\n- **text:** A template string for the plaintext content of the email.\n- **html:** A template string for the HTML content of the email.\n- **amp:** A template string for the [AMP4EMAIL](https://amp.dev/documentation/guides-and-tutorials/learn/email-spec/amp-email-format/) content of the email.\n- **attachments:** An array of attachments with template strings as values; [Nodemailer options](https://nodemailer.com/message/attachments/) supported: utf-8 string, custom content type, URL, encoded string, data URI, and pre-generated MIME node (be aware that your email has no access to the cloud server's file system).\n\nAn example template might have an ID of `following` and content like: \n\n {\n subject: \"@{{username}} is now following you!\",\n html: \"Just writing to let you know that \u003ccode\u003e@{{username}}\u003c/code\u003e ({{name}}) is now following you.\",\n attachments: [\n {\n filename: \"{{username}}.jpg\",\n path: \"{{imagePath}}\"\n }\n ]\n }\n\nSend emails using templates\n\nTo deliver email using templates, when adding documents to your mail collection,\ninclude a `template` field with `name` and `data` properties. For example,\nusing our `following` template from above: \n\n admin\n .firestore()\n .collection(\"MAIL_COLLECTION\")\n .add({\n toUids: [\"abc123\"],\n template: {\n name: \"following\",\n data: {\n username: \"ada\",\n name: \"Ada Lovelace\",\n imagePath: \"https://example.com/path/to/file/image-name.jpg\"\n },\n },\n });\n\nTemplate Partials\n\nYou can compose templates using reusable [partials](https://handlebarsjs.com/guide/partials.html)\nby specifying `{partial: true}` in the template document. Each of the standard\ndata fields (`subject`, `html`, `text`, and `amp`) will be defined as a partial\nused only in its own environment. For example, a partial called `footer` might\nhave data like: \n\n {\n partial: true,\n html: \"\u003cp\u003eThis mail was sent by ExampleApp, Inc. \u003ca href='https://example.com/unsubscribe'\u003eUnsubscribe\u003c/a\u003e\u003c/p\u003e\",\n text: \"This mail was sent by ExampleApp, Inc. Unsubscribe here: https://example.com/unsubscribe\"\n }\n\nIn another template, include the partial by referencing its name (document ID): \n\n \u003cp\u003eThis is my main template content, but it will use a common footer.\u003c/p\u003e\n\n {{\u003e footer }}"]]