diff --git a/app/assets/images/email/README.md b/app/assets/images/email/README.md new file mode 100644 index 000000000..c93a28f3b --- /dev/null +++ b/app/assets/images/email/README.md @@ -0,0 +1,21 @@ +# Email Assets + +Images in this folder are used in transactional emails sent by the planner +application. They are referenced via the Rails asset pipeline with digest +fingerprinting. + +## ⚠️ Do not modify or delete existing files + +The digest fingerprint is derived from the file content. Changing an image +here changes its URL. Any previously-sent email that references the old URL +will show a broken image in the recipient's inbox. + +**Additive changes only.** Need a new image for a new email? Add a new file. +Need a new logo? Add it as a new filename (e.g. `logo-2026.png`) and update +the mailer view to reference the new file. Never mutate an existing file. + +## Email stylesheet + +The email CSS lives at `app/assets/stylesheets/email.css` — not in this +folder — but it's referenced by mailer layouts via the pipeline path +`email.css`. diff --git a/app/assets/images/email/website-logo.png b/app/assets/images/email/website-logo.png new file mode 100644 index 000000000..ba919ed86 Binary files /dev/null and b/app/assets/images/email/website-logo.png differ diff --git a/app/views/shared_mailers/_body_header.html.haml b/app/views/shared_mailers/_body_header.html.haml index 0f753564d..600b679dc 100644 --- a/app/views/shared_mailers/_body_header.html.haml +++ b/app/views/shared_mailers/_body_header.html.haml @@ -6,8 +6,7 @@ %table{ bgcolor: "#fdfdfd" } %tr %td{ width: "40%" } - // TODO: maybe get this from codebar.io - = image_tag("https://raw.githubusercontent.com/codebar/assets/master/logo/png/website-logo.png", alt: "codebar logo") + = image_tag("email/website-logo.png", alt: "codebar logo") %td{ align: "right" } %h6.collapse= title %td diff --git a/app/views/shared_mailers/_header.html.haml b/app/views/shared_mailers/_header.html.haml index 00c215432..c68ebd13b 100644 --- a/app/views/shared_mailers/_header.html.haml +++ b/app/views/shared_mailers/_header.html.haml @@ -6,4 +6,4 @@ %meta{ 'http-equiv' => "Content-Type", content: "text/html; charset=UTF-8" } %title=title - %link{rel: "stylesheet", type: "text/css", href: "/assets/email.css"} + %link{rel: "stylesheet", type: "text/css", href: asset_path("email.css")} diff --git a/config/environments/development.rb b/config/environments/development.rb index 5da35e3b7..3f030ff3d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -43,6 +43,9 @@ # Set localhost to be used by links generated in mailer templates. config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + # Host for absolute asset URLs in emails (for local email preview). + config.action_mailer.asset_host = "http://localhost:3000" + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index 920dd1e47..6b16c5d3d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -68,6 +68,9 @@ # Set host to be used by links generated in mailer templates. config.action_mailer.default_url_options = { host: 'codebar.io' } + # Host for absolute asset URLs in emails. Override for staging via ASSET_HOST env var. + config.action_mailer.asset_host = ENV.fetch('ASSET_HOST', 'https://codebar.io') + # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. config.action_mailer.smtp_settings = { port: '587',