123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- package smtp
- const (
- // Common CSS styles shared across all email templates
- commonStyles = `
- body {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
- line-height: 1.6;
- color: #333;
- max-width: 600px;
- margin: 0 auto;
- padding: 20px;
- }
- .container {
- background-color: #ffffff;
- border: 1px solid #e1e1e1;
- border-radius: 5px;
- padding: 25px;
- margin-top: 20px;
- }
- .header {
- margin-bottom: 20px;
- padding-bottom: 20px;
- border-bottom: 1px solid #e1e1e1;
- }
- .content {
- margin-bottom: 20px;
- }
- .footer {
- margin-top: 20px;
- padding-top: 20px;
- border-top: 1px solid #e1e1e1;
- font-size: 0.9em;
- color: #666;
- }
- .button {
- display: inline-block;
- padding: 10px 20px;
- background-color: #007bff;
- color: #ffffff;
- text-decoration: none;
- border-radius: 5px;
- margin: 15px 0;
- }
- .button:hover {
- background-color: #0056b3;
- }
- @media only screen and (max-width: 600px) {
- body {
- padding: 10px;
- }
- .container {
- padding: 15px;
- }
- }
- `
- // Template-specific styles
- defaultStyles = ``
- verificationStyles = `
- .content {
- text-align: center;
- }
- .button {
- padding: 12px 24px;
- background-color: #28a745;
- font-weight: bold;
- }
- .button:hover {
- background-color: #218838;
- }
- .verification-link {
- margin: 20px 0;
- padding: 15px;
- background-color: #f8f9fa;
- border: 1px solid #e1e1e1;
- border-radius: 5px;
- word-break: break-all;
- }
- `
- welcomeStyles = `
- .credentials {
- background-color: #f8f9fa;
- border: 1px solid #e1e1e1;
- border-radius: 5px;
- padding: 20px;
- margin: 20px 0;
- }
- .credential-item {
- margin: 10px 0;
- }
- .label {
- font-weight: bold;
- color: #495057;
- }
- .value {
- font-family: monospace;
- background-color: #e9ecef;
- padding: 2px 6px;
- border-radius: 3px;
- }
- `
- // Email templates with shared and specific styles
- defaultTemplate = `
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>{{.Subject}}</title>
- <style>
- ` + commonStyles + defaultStyles + `
- </style>
- </head>
- <body>
- <div class="container">
- <div class="header">
- <h1>{{.Subject}}</h1>
- </div>
- <div class="content">
- {{.Body}}
- </div>
- <div class="footer">
- <p>This is an automated message, please do not reply directly to this email.</p>
- </div>
- </div>
- </body>
- </html>
- `
- verificationTemplate = `
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Email Verification</title>
- <style>
- ` + commonStyles + verificationStyles + `
- </style>
- </head>
- <body>
- <div class="container">
- <div class="header">
- <h1>Verify Your Email</h1>
- </div>
- <div class="content">
- <p>Thank you for registering. Please click the button below to verify your email address:</p>
- <a href="{{.VerificationURL}}" class="button">Verify Email</a>
- <div class="verification-link">
- <p>If the button doesn't work, copy and paste this link into your browser:</p>
- <code>{{.VerificationURL}}</code>
- </div>
- </div>
- <div class="footer">
- <p>If you didn't create an account, you can safely ignore this email.</p>
- </div>
- </div>
- </body>
- </html>
- `
- welcomeTemplate = `
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Welcome!</title>
- <style>
- ` + commonStyles + welcomeStyles + `
- </style>
- </head>
- <body>
- <div class="container">
- <div class="header">
- <h1>Welcome!</h1>
- </div>
- <div class="content">
- <p>Your account has been successfully created. Here are your access details:</p>
-
- <div class="credentials">
- <div class="credential-item">
- <span class="label">Username:</span>
- <span class="value">{{.Username}}</span>
- </div>
- <div class="credential-item">
- <span class="label">Password:</span>
- <span class="value">{{.Password}}</span>
- </div>
- {{if .WebAppURL}}
- <div class="credential-item">
- <span class="label">Application URL:</span>
- <span class="value">{{.WebAppURL}}</span>
- </div>
- {{end}}
- </div>
- {{if .WebAppURL}}
- <a href="{{.WebAppURL}}" class="button">Access Your Account</a>
- {{end}}
-
- <p><strong>Important:</strong> Please change your password upon your first login.</p>
- </div>
- <div class="footer">
- <p>If you need any assistance, please contact our support team.</p>
- </div>
- </div>
- </body>
- </html>
- `
- )
|