HTMLメール
This commit is contained in:
		
							parent
							
								
									cc9bc7703a
								
							
						
					
					
						commit
						263032b680
					
				
					 2 changed files with 82 additions and 2 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								assets/mi-white.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/mi-white.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 18 KiB | 
|  | @ -8,6 +8,9 @@ export const logger = new Logger('email'); | |||
| export async function sendEmail(to: string, subject: string, text: string) { | ||||
| 	const meta = await fetchMeta(true); | ||||
| 
 | ||||
| 	const iconUrl = `${config.url}/assets/mi-white.png`; | ||||
| 	const emailSettingUrl = `${config.url}/settings/email`; | ||||
| 
 | ||||
| 	const enableAuth = meta.smtpUser != null && meta.smtpUser !== ''; | ||||
| 
 | ||||
| 	const transporter = nodemailer.createTransport({ | ||||
|  | @ -26,8 +29,85 @@ export async function sendEmail(to: string, subject: string, text: string) { | |||
| 		const info = await transporter.sendMail({ | ||||
| 			from: meta.email!, | ||||
| 			to: to, | ||||
| 			subject: subject || 'Misskey', | ||||
| 			text: text | ||||
| 			subject: subject, | ||||
| 			text: text, | ||||
| 			html: `<!doctype html>
 | ||||
| 			<html> | ||||
| 				<head> | ||||
| 					<meta charset="utf-8"> | ||||
| 					<title>${ subject }</title> | ||||
| 					<style> | ||||
| 						html { | ||||
| 							background: #eee; | ||||
| 						} | ||||
| 
 | ||||
| 						body { | ||||
| 							padding: 16px; | ||||
| 						} | ||||
| 
 | ||||
| 						a { | ||||
| 							text-decoration: none; | ||||
| 							color: #86b300; | ||||
| 						} | ||||
| 						a:hover { | ||||
| 							text-decoration: underline; | ||||
| 						} | ||||
| 
 | ||||
| 						main { | ||||
| 							max-width: 500px; | ||||
| 							margin: 0 auto; | ||||
| 							background: #fff; | ||||
| 							color: #555; | ||||
| 						} | ||||
| 							main > header { | ||||
| 								padding: 32px; | ||||
| 								background: #86b300; | ||||
| 							} | ||||
| 								main > header > img { | ||||
| 									max-width: 128px; | ||||
| 									max-height: 28px; | ||||
| 								} | ||||
| 							main > article { | ||||
| 								padding: 32px; | ||||
| 							} | ||||
| 								main > article > h1 { | ||||
| 									margin: 0 0 1em 0; | ||||
| 								} | ||||
| 							main > footer { | ||||
| 								padding: 32px; | ||||
| 								border-top: solid 1px #eee; | ||||
| 							} | ||||
| 
 | ||||
| 						nav { | ||||
| 							box-sizing: border-box; | ||||
| 							max-width: 500px; | ||||
| 							margin: 16px auto 0 auto; | ||||
| 							padding: 0 32px; | ||||
| 						} | ||||
| 							nav > a { | ||||
| 								color: #888; | ||||
| 							} | ||||
| 					</style> | ||||
| 				</head> | ||||
| 				<body> | ||||
| 					<main> | ||||
| 						<header> | ||||
| 							<img src="${ meta.logoImageUrl || meta.iconUrl || iconUrl }"/> | ||||
| 						</header> | ||||
| 						<article> | ||||
| 							<h1>${ subject }</h1> | ||||
| 							<div>${ text }</div> | ||||
| 						</article> | ||||
| 						<footer> | ||||
| 							<a href="${ emailSettingUrl }">${ 'Email setting' }</a> | ||||
| 						</footer> | ||||
| 					</main> | ||||
| 					<nav> | ||||
| 						<a href="${ config.url }">${ config.host }</a> | ||||
| 					</nav> | ||||
| 				</body> | ||||
| 			</html> | ||||
| 			` | ||||
| 		}); | ||||
| 
 | ||||
| 		logger.info('Message sent: %s', info.messageId); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue