templates.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. package smtp
  2. const (
  3. // Common CSS styles shared across all email templates
  4. commonStyles = `
  5. body {
  6. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  7. line-height: 1.6;
  8. color: #333;
  9. max-width: 600px;
  10. margin: 0 auto;
  11. padding: 20px;
  12. }
  13. .container {
  14. background-color: #ffffff;
  15. border: 1px solid #e1e1e1;
  16. border-radius: 5px;
  17. padding: 25px;
  18. margin-top: 20px;
  19. }
  20. .header {
  21. margin-bottom: 20px;
  22. padding-bottom: 20px;
  23. border-bottom: 1px solid #e1e1e1;
  24. }
  25. .content {
  26. margin-bottom: 20px;
  27. }
  28. .footer {
  29. margin-top: 20px;
  30. padding-top: 20px;
  31. border-top: 1px solid #e1e1e1;
  32. font-size: 0.9em;
  33. color: #666;
  34. }
  35. .button {
  36. display: inline-block;
  37. padding: 10px 20px;
  38. background-color: #007bff;
  39. color: #ffffff;
  40. text-decoration: none;
  41. border-radius: 5px;
  42. margin: 15px 0;
  43. }
  44. .button:hover {
  45. background-color: #0056b3;
  46. }
  47. @media only screen and (max-width: 600px) {
  48. body {
  49. padding: 10px;
  50. }
  51. .container {
  52. padding: 15px;
  53. }
  54. }
  55. `
  56. // Template-specific styles
  57. defaultStyles = ``
  58. verificationStyles = `
  59. .content {
  60. text-align: center;
  61. }
  62. .button {
  63. padding: 12px 24px;
  64. background-color: #28a745;
  65. font-weight: bold;
  66. }
  67. .button:hover {
  68. background-color: #218838;
  69. }
  70. .verification-link {
  71. margin: 20px 0;
  72. padding: 15px;
  73. background-color: #f8f9fa;
  74. border: 1px solid #e1e1e1;
  75. border-radius: 5px;
  76. word-break: break-all;
  77. }
  78. `
  79. welcomeStyles = `
  80. .credentials {
  81. background-color: #f8f9fa;
  82. border: 1px solid #e1e1e1;
  83. border-radius: 5px;
  84. padding: 20px;
  85. margin: 20px 0;
  86. }
  87. .credential-item {
  88. margin: 10px 0;
  89. }
  90. .label {
  91. font-weight: bold;
  92. color: #495057;
  93. }
  94. .value {
  95. font-family: monospace;
  96. background-color: #e9ecef;
  97. padding: 2px 6px;
  98. border-radius: 3px;
  99. }
  100. `
  101. // Email templates with shared and specific styles
  102. defaultTemplate = `
  103. <!DOCTYPE html>
  104. <html>
  105. <head>
  106. <meta charset="UTF-8">
  107. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  108. <title>{{.Subject}}</title>
  109. <style>
  110. ` + commonStyles + defaultStyles + `
  111. </style>
  112. </head>
  113. <body>
  114. <div class="container">
  115. <div class="header">
  116. <h1>{{.Subject}}</h1>
  117. </div>
  118. <div class="content">
  119. {{.Body}}
  120. </div>
  121. <div class="footer">
  122. <p>This is an automated message, please do not reply directly to this email.</p>
  123. </div>
  124. </div>
  125. </body>
  126. </html>
  127. `
  128. verificationTemplate = `
  129. <!DOCTYPE html>
  130. <html>
  131. <head>
  132. <meta charset="UTF-8">
  133. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  134. <title>Email Verification</title>
  135. <style>
  136. ` + commonStyles + verificationStyles + `
  137. </style>
  138. </head>
  139. <body>
  140. <div class="container">
  141. <div class="header">
  142. <h1>Verify Your Email</h1>
  143. </div>
  144. <div class="content">
  145. <p>Thank you for registering. Please click the button below to verify your email address:</p>
  146. <a href="{{.VerificationURL}}" class="button">Verify Email</a>
  147. <div class="verification-link">
  148. <p>If the button doesn't work, copy and paste this link into your browser:</p>
  149. <code>{{.VerificationURL}}</code>
  150. </div>
  151. </div>
  152. <div class="footer">
  153. <p>If you didn't create an account, you can safely ignore this email.</p>
  154. </div>
  155. </div>
  156. </body>
  157. </html>
  158. `
  159. welcomeTemplate = `
  160. <!DOCTYPE html>
  161. <html>
  162. <head>
  163. <meta charset="UTF-8">
  164. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  165. <title>Welcome!</title>
  166. <style>
  167. ` + commonStyles + welcomeStyles + `
  168. </style>
  169. </head>
  170. <body>
  171. <div class="container">
  172. <div class="header">
  173. <h1>Welcome!</h1>
  174. </div>
  175. <div class="content">
  176. <p>Your account has been successfully created. Here are your access details:</p>
  177. <div class="credentials">
  178. <div class="credential-item">
  179. <span class="label">Username:</span>
  180. <span class="value">{{.Username}}</span>
  181. </div>
  182. <div class="credential-item">
  183. <span class="label">Password:</span>
  184. <span class="value">{{.Password}}</span>
  185. </div>
  186. {{if .WebAppURL}}
  187. <div class="credential-item">
  188. <span class="label">Application URL:</span>
  189. <span class="value">{{.WebAppURL}}</span>
  190. </div>
  191. {{end}}
  192. </div>
  193. {{if .WebAppURL}}
  194. <a href="{{.WebAppURL}}" class="button">Access Your Account</a>
  195. {{end}}
  196. <p><strong>Important:</strong> Please change your password upon your first login.</p>
  197. </div>
  198. <div class="footer">
  199. <p>If you need any assistance, please contact our support team.</p>
  200. </div>
  201. </div>
  202. </body>
  203. </html>
  204. `
  205. )