materia v0.1.2 Materia.Mails

The Mails context.

Link to this section Summary

Functions

Creates a mail_template

Deletes a MailTemplate

Gets a single mail_template

iex(1)> mail_templates = Materia.Mails.list_mail_templates_by_params(%{"and" => [%{"mail_template_type" => "temp_registration"}]})
iex(2)> MateriaWeb.MailTemplateView.render("index.json", %{mail_templates: mail_templates})
%{
  data: [
    %{
      body: "{!email}様
この度は当サービスへ仮登録をいただき誠にありがとうございます。

Returns the list of mail_templates

Returns the list of mail_templates

Link to this section Functions

Link to this function create_mail_template(attrs \\ %{})

Creates a mail_template.

Examples

iex(1)> {:ok, mail_template} = Materia.Mails.create_mail_template(%{mail_template_type: "test_tamplate", subject: "test_subject", body: "test body"})
iex(2)> MateriaWeb.MailTemplateView.render("show.json", %{mail_template: mail_template}) |> Map.delete(:id)
%{
  body: "test body",
  lock_version: 1,
  mail_template_type: "test_tamplate",
  status: 1,
  subject: "test_subject"
}
Link to this function delete_mail_template(mail_template)

Deletes a MailTemplate.

Examples

iex(1)> mail_template = Materia.Mails.get_mail_template!(1)
iex(2)> {:ok, mail_template} = Materia.Mails.delete_mail_template(mail_template)
iex(3)> mail_templates = Materia.Mails.list_mail_templates()
iex(4)> MateriaWeb.MailTemplateView.render("index.json", %{mail_templates: mail_templates})
[
  %{
    body: "{!name}様
この度は当サービスのご利用誠にありがとうございます。

本登録が完了いたしました。

IDの問い合わせ機能はない為、本メールを大切に保管してください。

  ユーザーID: {!email}
  パスワード: 登録時に入力いただいたパスワード
 本サービスを末長くよろしくお願いいたします。

 https://{!sign_in_url} 

------------------------------
カラビナテクノロジー株式会社
〒810-0001 
福岡市中央区天神1-2-4 農業共済ビル2F
------------------------------",
    id: 2,
    lock_version: 1,
    mail_template_type: "registerd",
    status: 1,
    subject: "【本登録完了しました{!name}様 本登録完了のご案内"
  },
]
Link to this function get_mail_template!(id)

Gets a single mail_template.

Raises Ecto.NoResultsError if the MailTemplate does not exist.

Examples

iex(1)> mail_template = Materia.Mails.get_mail_template!(1)
iex(34)> MateriaWeb.MailTemplateView.render("show.json", %{mail_template: mail_template})
%{
  body: "{!email}様
この度は当サービスへ仮登録をいただき誠にありがとうございます。

本登録のご案内をいたます。

下記URLのリンクをクリックし、必要情報を入力の上、30分以内に本登録操作の完了をお願いいたします。
操作完了後"【本登録完了しました】"のタイトルのメールが届きましたら本登録完了となります。

 https://{!user_registration_url}?param=!{user_regstration_token} 

------------------------------
カラビナテクノロジー株式会社
〒810-0001 
福岡市中央区天神1-2-4 農業共済ビル2F
------------------------------",
  id: 1,
  lock_version: 1,
  mail_template_type: "temp_registration",
  status: 1,
  subject: "【注意!登録は完了していません】本登録のご案内"
}
Link to this function get_mail_template_by_mail_template_type(mail_template_type)
iex(1)> mail_templates = Materia.Mails.list_mail_templates_by_params(%{"and" => [%{"mail_template_type" => "temp_registration"}]})
iex(2)> MateriaWeb.MailTemplateView.render("index.json", %{mail_templates: mail_templates})
%{
  data: [
    %{
      body: "{!email}様
この度は当サービスへ仮登録をいただき誠にありがとうございます。

本登録のご案内をいたます。

下記URLのリンクをクリックし、必要情報を入力の上、30分以内に本登録操作の完了をお願いいたします。
操作完了後"【本登録完了しました】"のタイトルのメールが届きましたら本登録完了となります。

 https://{!user_registration_url}?param=!{user_regstration_token} 

------------------------------
カラビナテクノロジー株式会社
〒810-0001 
福岡市中央区天神1-2-4 農業共済ビル2F
------------------------------",
      id: 1,
      lock_version: 1,
      mail_template_type: "temp_registration",
      status: 1,
      subject: "【注意!登録は完了していません】本登録のご案内"
    }
  ]
}
Link to this function list_mail_templates()

Returns the list of mail_templates.

Examples

iex(1)> templates = Materia.Mails.list_mail_templates()
iex(7)> MateriaWeb.MailTemplateView.render("index.json", %{mail_templates: mail_templates})
[
  %{
    body: "{!email}様
この度は当サービスへ仮登録をいただき誠にありがとうございます。

本登録のご案内をいたます。

下記URLのリンクをクリックし、必要情報を入力の上、30分以内に本登録操作の完了をお願いいたします。
操作完了後"【本登録完了しました】"のタイトルのメールが届きましたら本登録完了となります。

 https://{!user_registration_url}?param=!{user_regstration_token} 

------------------------------
カラビナテクノロジー株式会社
〒810-0001 
福岡市中央区天神1-2-4 農業共済ビル2F
------------------------------",
    id: 1,
    lock_version: 1,
    mail_template_type: "temp_registration",
    status: 1,
    subject: "【注意!登録は完了していません】本登録のご案内"
  }
]
Link to this function list_mail_templates_by_params(params)

Returns the list of mail_templates.

Examples

iex(1)> mail_templates = Materia.Mails.list_mail_templates_by_params(%{"and" => [%{"mail_template_type" => "temp_registration"}]})
iex(2)> MateriaWeb.MailTemplateView.render("index.json", %{mail_templates: mail_templates})
[
  %{
    body: "{!email}様
この度は当サービスへ仮登録をいただき誠にありがとうございます。

本登録のご案内をいたます。

下記URLのリンクをクリックし、必要情報を入力の上、30分以内に本登録操作の完了をお願いいたします。
操作完了後"【本登録完了しました】"のタイトルのメールが届きましたら本登録完了となります。

 https://{!user_registration_url}?param=!{user_regstration_token} 

------------------------------
カラビナテクノロジー株式会社
〒810-0001 
福岡市中央区天神1-2-4 農業共済ビル2F
------------------------------",
    id: 1,
    lock_version: 1,
    mail_template_type: "temp_registration",
    status: 1,
    subject: "【注意!登録は完了していません】本登録のご案内"
  }
]
Link to this function send_mail(from_email, to_email, subject, body, replace_list, from_name \\ nil)

send mail action.

Examples

iex(1)> {:ok, result} = Materia.Mails.send_mail("from@example.com", "test@example.com", "test subject to {!name}", "Dier {!name} 
 mail to %email%", [{"{!name}", "test user"}, {"%email%", "test@example.com"}], "test admin")
{:ok,
%{
  body_text: "Dier test user 
 mail to test@example.com",
  from: "from@example.com",
  from_name: "test admin",
  subject: "test subject to test user",
  to: "test@example.com"
}}
Link to this function update_mail_template(mail_template, attrs)

Updates a mail_template.

Examples

iex(1)> mail_template = Materia.Mails.get_mail_template!(1)
iex(2)> {:ok, updated_mail_template} = Materia.Mails.update_mail_template(mail_template, %{subject: "test_subject"})
iex(3)> MateriaWeb.MailTemplateView.render("show.json", %{mail_template: updated_mail_template})
%{
  body: "{!email}様
この度は当サービスへ仮登録をいただき誠にありがとうございます。

本登録のご案内をいたます。

下記URLのリンクをクリックし、必要情報を入力の上、30分以内に本登録操作の完了をお願いいたします。
操作完了後"【本登録完了しました】"のタイトルのメールが届きましたら本登録完了となります。

 https://{!user_registration_url}?param=!{user_regstration_token} 

------------------------------
カラビナテクノロジー株式会社
〒810-0001 
福岡市中央区天神1-2-4 農業共済ビル2F
------------------------------",
  id: 1,
  lock_version: 2,
  mail_template_type: "temp_registration",
  status: 1,
  subject: "test_subject"
}