diff --git a/src/email-templates/contact/contact-admin.html b/src/email-templates/contact/contact-admin.html new file mode 100644 index 0000000000000000000000000000000000000000..c2b14df42c014aaa1832de4c8b363c06a5828c46 --- /dev/null +++ b/src/email-templates/contact/contact-admin.html @@ -0,0 +1,28 @@ +<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title>Contact</title><!--[if !mso]><!-- --><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style type="text/css">#outlook a { padding:0; } + .ReadMsgBody { width:100%; } + .ExternalClass { width:100%; } + .ExternalClass * { line-height:100%; } + body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } + table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } + img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } + p { display:block;margin:13px 0; }</style><!--[if !mso]><!--><style type="text/css">@media only screen and (max-width:480px) { + @-ms-viewport { width:320px; } + @viewport { width:320px; } + }</style><!--<![endif]--><!--[if mso]> + <xml> + <o:OfficeDocumentSettings> + <o:AllowPNG/> + <o:PixelsPerInch>96</o:PixelsPerInch> + </o:OfficeDocumentSettings> + </xml> + <![endif]--><!--[if lte mso 11]> + <style type="text/css"> + .outlook-group-fix { width:100% !important; } + </style> + <![endif]--><!--[if !mso]><!--><link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"><style type="text/css">@import url(https://fonts.googleapis.com/css?family=Lato);</style><!--<![endif]--><style type="text/css">@media only screen and (min-width:480px) { + .mj-column-per-100 { width:100% !important; max-width: 100%; } + }</style><style type="text/css">@media only screen and (max-width:480px) { + table.full-width-mobile { width: 100% !important; } + td.full-width-mobile { width: auto !important; } + }</style></head><body><div><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="border:1px solid #ccc;direction:ltr;font-size:0px;padding:0px 0px;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:white;background-color:white;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:white;background-color:white;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:250px;"><img height="auto" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/datagrandlyoncom.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;" width="250"></td></tr></tbody></table></td></tr><tr><td style="font-size:0px;padding:10px 25px;word-break:break-word;"><p style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:100%;"></p><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:548px;" role="presentation" width="548px" ><tr><td style="height:0;line-height:0;"> +</td></tr></table><![endif]--></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Une demande de contact a récemment été déposée par l'utilisateur ${options.firstName} ${options.lastName}.</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Email:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;padding-left:40px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.email}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Sujet:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;padding-left:40px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.subject}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Message:</div></td></tr><tr><td align="left" class="pre" style="white-space: pre; font-size: 0px; padding: 10px 25px; padding-left: 40px; word-break: break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.message}</div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:#ed1c24;background-color:#ed1c24;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ed1c24;background-color:#ed1c24;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" ><tr><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://download.data.grandlyon.com/catalogue/srv/fre/rss.search?sortBy=publicationDate&georss=simplepoint&data" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/rss.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="http://www.facebook.com/legrandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/facebook.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://twitter.com/grandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/twitter.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html> \ No newline at end of file diff --git a/src/email-templates/contact/contact-admin.mjml b/src/email-templates/contact/contact-admin.mjml new file mode 100644 index 0000000000000000000000000000000000000000..6569e1d7a44e4fe5c64e8566d8f716b579b6eaeb --- /dev/null +++ b/src/email-templates/contact/contact-admin.mjml @@ -0,0 +1,65 @@ +<mjml> + <mj-head> + <mj-title>Contact</mj-title> + <mj-font name="Lato" href="https://fonts.googleapis.com/css?family=Lato" /> + <mj-attributes> + <mj-text font-family="Lato" line-height="25px" font-size="16px" /> + </mj-attributes> + <mj-style inline="inline"> + .pre { + white-space: pre; + } + </mj-style> + </mj-head> + <mj-body> + <mj-wrapper border="1px solid #ccc" padding="0px 0px"> + <mj-section background-color="white"> + <mj-column> + + <mj-image width="250px" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/datagrandlyoncom.png"></mj-image> + + <mj-divider border-color="#ed1c24"></mj-divider> + + <mj-text>Une demande de contact a récemment été déposée par l'utilisateur ${options.firstName} ${options.lastName}.</mj-text> + + <mj-text text-decoration="underline"> + Email: + </mj-text> + + <mj-text padding-left="40px"> + ${options.email} + </mj-text> + + <mj-text text-decoration="underline"> + Sujet: + </mj-text> + + <mj-text padding-left="40px">${options.subject}</mj-text> + + <mj-text text-decoration="underline"> + Message: + </mj-text> + + <mj-text padding-left="40px" css-class="pre"> + ${options.message} + </mj-text> + + </mj-text> + </mj-column> + </mj-section> + + <mj-section background-color="#ed1c24"> + <mj-column> + <mj-social font-size="15px" icon-size="25px" mode="horizontal"> + <mj-social-element href="https://download.data.grandlyon.com/catalogue/srv/fre/rss.search?sortBy=publicationDate&georss=simplepoint&data" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/rss.png"> + </mj-social-element> + <mj-social-element href="http://www.facebook.com/legrandlyon" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/facebook.png"> + </mj-social-element> + <mj-social-element href="https://twitter.com/grandlyon" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/twitter.png"> + </mj-social-element> + </mj-social> + </mj-column> + </mj-section> + </mj-wrapper> + </mj-body> +</mjml> \ No newline at end of file diff --git a/src/email-templates/contact/contact-user.html b/src/email-templates/contact/contact-user.html new file mode 100644 index 0000000000000000000000000000000000000000..2da894ed464c5dd92a87e74a34f9fbd4dbd94201 --- /dev/null +++ b/src/email-templates/contact/contact-user.html @@ -0,0 +1,28 @@ +<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title>Contact</title><!--[if !mso]><!-- --><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style type="text/css">#outlook a { padding:0; } + .ReadMsgBody { width:100%; } + .ExternalClass { width:100%; } + .ExternalClass * { line-height:100%; } + body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } + table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } + img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } + p { display:block;margin:13px 0; }</style><!--[if !mso]><!--><style type="text/css">@media only screen and (max-width:480px) { + @-ms-viewport { width:320px; } + @viewport { width:320px; } + }</style><!--<![endif]--><!--[if mso]> + <xml> + <o:OfficeDocumentSettings> + <o:AllowPNG/> + <o:PixelsPerInch>96</o:PixelsPerInch> + </o:OfficeDocumentSettings> + </xml> + <![endif]--><!--[if lte mso 11]> + <style type="text/css"> + .outlook-group-fix { width:100% !important; } + </style> + <![endif]--><!--[if !mso]><!--><link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"><style type="text/css">@import url(https://fonts.googleapis.com/css?family=Lato);</style><!--<![endif]--><style type="text/css">@media only screen and (min-width:480px) { + .mj-column-per-100 { width:100% !important; max-width: 100%; } + }</style><style type="text/css">@media only screen and (max-width:480px) { + table.full-width-mobile { width: 100% !important; } + td.full-width-mobile { width: auto !important; } + }</style></head><body><div><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="border:1px solid #ccc;direction:ltr;font-size:0px;padding:0px 0px;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:white;background-color:white;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:white;background-color:white;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:250px;"><img height="auto" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/datagrandlyoncom.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;" width="250"></td></tr></tbody></table></td></tr><tr><td style="font-size:0px;padding:10px 25px;word-break:break-word;"><p style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:100%;"></p><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:548px;" role="presentation" width="548px" ><tr><td style="height:0;line-height:0;"> +</td></tr></table><![endif]--></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Bonjour,</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Vous nous avez récemment contacté via le formulaire de contact de la plateforme data.grandlyon.com.</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Voici un résumé de votre demande:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Sujet:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;padding-left:40px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.subject}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Message:</div></td></tr><tr><td align="left" class="pre" style="white-space: pre; font-size: 0px; padding: 10px 25px; padding-left: 40px; word-break: break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.message}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Nous reviendrons vers vous dans les plus brefs délais.</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">L'équipe de data.grandlyon.com</div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:#ed1c24;background-color:#ed1c24;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ed1c24;background-color:#ed1c24;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" ><tr><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://download.data.grandlyon.com/catalogue/srv/fre/rss.search?sortBy=publicationDate&georss=simplepoint&data" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/rss.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="http://www.facebook.com/legrandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/facebook.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://twitter.com/grandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/twitter.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html> \ No newline at end of file diff --git a/src/email-templates/contact/contact-user.mjml b/src/email-templates/contact/contact-user.mjml new file mode 100644 index 0000000000000000000000000000000000000000..1d4488300baa5621545c78cf1e3348a9ede96a7a --- /dev/null +++ b/src/email-templates/contact/contact-user.mjml @@ -0,0 +1,67 @@ +<mjml> + <mj-head> + <mj-title>Contact</mj-title> + <mj-font name="Lato" href="https://fonts.googleapis.com/css?family=Lato" /> + <mj-attributes> + <mj-text font-family="Lato" line-height="25px" font-size="16px" /> + </mj-attributes> + <mj-style inline="inline"> + .pre { + white-space: pre; + } + </mj-style> + </mj-head> + <mj-body> + <mj-wrapper border="1px solid #ccc" padding="0px 0px"> + <mj-section background-color="white"> + <mj-column> + + <mj-image width="250px" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/datagrandlyoncom.png"></mj-image> + + <mj-divider border-color="#ed1c24"></mj-divider> + + <mj-text>Bonjour,</mj-text> + + <mj-text>Vous nous avez récemment contacté via le formulaire de contact de la plateforme data.grandlyon.com.</mj-text> + + <mj-text>Voici un résumé de votre demande:</mj-text> + + <mj-text text-decoration="underline"> + Sujet: + </mj-text> + + <mj-text padding-left="40px">${options.subject}</mj-text> + + <mj-text text-decoration="underline"> + Message: + </mj-text> + + <mj-text padding-left="40px" css-class="pre"> + ${options.message} + </mj-text> + + <mj-text>Nous reviendrons vers vous dans les plus brefs délais.</mj-text> + + <mj-text> + L'équipe de data.grandlyon.com + </mj-text> + + </mj-text> + </mj-column> + </mj-section> + + <mj-section background-color="#ed1c24"> + <mj-column> + <mj-social font-size="15px" icon-size="25px" mode="horizontal"> + <mj-social-element href="https://download.data.grandlyon.com/catalogue/srv/fre/rss.search?sortBy=publicationDate&georss=simplepoint&data" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/rss.png"> + </mj-social-element> + <mj-social-element href="http://www.facebook.com/legrandlyon" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/facebook.png"> + </mj-social-element> + <mj-social-element href="https://twitter.com/grandlyon" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/twitter.png"> + </mj-social-element> + </mj-social> + </mj-column> + </mj-section> + </mj-wrapper> + </mj-body> +</mjml> \ No newline at end of file diff --git a/src/email-templates/contact/index.ts b/src/email-templates/contact/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c506d4976627a67698da3c420b23bc10414d041 --- /dev/null +++ b/src/email-templates/contact/index.ts @@ -0,0 +1,78 @@ +export const buildContactUserEmail = (options: ContactUserEmailBodyOptions) => { + const html = `<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title>Contact</title><!--[if !mso]><!-- --><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style type="text/css">#outlook a { padding:0; } + .ReadMsgBody { width:100%; } + .ExternalClass { width:100%; } + .ExternalClass * { line-height:100%; } + body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } + table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } + img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } + p { display:block;margin:13px 0; }</style><!--[if !mso]><!--><style type="text/css">@media only screen and (max-width:480px) { + @-ms-viewport { width:320px; } + @viewport { width:320px; } + }</style><!--<![endif]--><!--[if mso]> +<xml> +<o:OfficeDocumentSettings> + <o:AllowPNG/> + <o:PixelsPerInch>96</o:PixelsPerInch> +</o:OfficeDocumentSettings> +</xml> +<![endif]--><!--[if lte mso 11]> +<style type="text/css"> + .outlook-group-fix { width:100% !important; } +</style> +<![endif]--><!--[if !mso]><!--><link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"><style type="text/css">@import url(https://fonts.googleapis.com/css?family=Lato);</style><!--<![endif]--><style type="text/css">@media only screen and (min-width:480px) { +.mj-column-per-100 { width:100% !important; max-width: 100%; } +}</style><style type="text/css">@media only screen and (max-width:480px) { +table.full-width-mobile { width: 100% !important; } +td.full-width-mobile { width: auto !important; } +}</style></head><body><div><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="border:1px solid #ccc;direction:ltr;font-size:0px;padding:0px 0px;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:white;background-color:white;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:white;background-color:white;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:250px;"><img height="auto" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/datagrandlyoncom.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;" width="250"></td></tr></tbody></table></td></tr><tr><td style="font-size:0px;padding:10px 25px;word-break:break-word;"><p style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:100%;"></p><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:548px;" role="presentation" width="548px" ><tr><td style="height:0;line-height:0;"> +</td></tr></table><![endif]--></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Bonjour,</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Vous nous avez récemment contacté via le formulaire de contact de la plateforme data.grandlyon.com.</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Voici un résumé de votre demande:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Sujet:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;padding-left:40px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.subject}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Message:</div></td></tr><tr><td align="left" class="pre" style="white-space: pre; font-size: 0px; padding: 10px 25px; padding-left: 40px; word-break: break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.message}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Nous reviendrons vers vous dans les plus brefs délais.</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">L'équipe de data.grandlyon.com</div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:#ed1c24;background-color:#ed1c24;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ed1c24;background-color:#ed1c24;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" ><tr><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://download.data.grandlyon.com/catalogue/srv/fre/rss.search?sortBy=publicationDate&georss=simplepoint&data" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/rss.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="http://www.facebook.com/legrandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/facebook.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://twitter.com/grandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/twitter.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html>`; + + return html; +}; + +export const buildContactAdminEmail = (options: ContactAdminEmailBodyOptions) => { + const html = `<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title>Contact</title><!--[if !mso]><!-- --><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style type="text/css">#outlook a { padding:0; } + .ReadMsgBody { width:100%; } + .ExternalClass { width:100%; } + .ExternalClass * { line-height:100%; } + body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } + table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } + img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } + p { display:block;margin:13px 0; }</style><!--[if !mso]><!--><style type="text/css">@media only screen and (max-width:480px) { + @-ms-viewport { width:320px; } + @viewport { width:320px; } + }</style><!--<![endif]--><!--[if mso]> +<xml> +<o:OfficeDocumentSettings> + <o:AllowPNG/> + <o:PixelsPerInch>96</o:PixelsPerInch> +</o:OfficeDocumentSettings> +</xml> +<![endif]--><!--[if lte mso 11]> +<style type="text/css"> + .outlook-group-fix { width:100% !important; } +</style> +<![endif]--><!--[if !mso]><!--><link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"><style type="text/css">@import url(https://fonts.googleapis.com/css?family=Lato);</style><!--<![endif]--><style type="text/css">@media only screen and (min-width:480px) { +.mj-column-per-100 { width:100% !important; max-width: 100%; } +}</style><style type="text/css">@media only screen and (max-width:480px) { +table.full-width-mobile { width: 100% !important; } +td.full-width-mobile { width: auto !important; } +}</style></head><body><div><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="border:1px solid #ccc;direction:ltr;font-size:0px;padding:0px 0px;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:white;background-color:white;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:white;background-color:white;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:250px;"><img height="auto" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/datagrandlyoncom.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;" width="250"></td></tr></tbody></table></td></tr><tr><td style="font-size:0px;padding:10px 25px;word-break:break-word;"><p style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:100%;"></p><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 4px #ed1c24;font-size:1;margin:0px auto;width:548px;" role="presentation" width="548px" ><tr><td style="height:0;line-height:0;"> +</td></tr></table><![endif]--></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">Une demande de contact a récemment été déposée par l'utilisateur ${options.firstName} ${options.lastName}.</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Email:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;padding-left:40px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.email}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Sujet:</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;padding-left:40px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.subject}</div></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;text-decoration:underline;color:#000000;">Message:</div></td></tr><tr><td align="left" class="pre" style="white-space: pre; font-size: 0px; padding: 10px 25px; padding-left: 40px; word-break: break-word;"><div style="font-family:Lato;font-size:16px;line-height:25px;text-align:left;color:#000000;">${options.message}</div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:598px;" width="598" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:#ed1c24;background-color:#ed1c24;Margin:0px auto;max-width:598px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ed1c24;background-color:#ed1c24;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" ><tr><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://download.data.grandlyon.com/catalogue/srv/fre/rss.search?sortBy=publicationDate&georss=simplepoint&data" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/rss.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="http://www.facebook.com/legrandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/facebook.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td><td><![endif]--><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="float:none;display:inline-table;"><tr><td style="padding:4px;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-radius:3px;width:25px;"><tr><td style="font-size:0;height:25px;vertical-align:middle;width:25px;"><a href="https://twitter.com/grandlyon" target="_blank"><img height="25" src="https://highway-to-data.alpha.grandlyon.com/email-template-assets/twitter.png" style="border-radius:3px;" width="25"></a></td></tr></table></td></tr></table><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html>`; + + return html; +}; + +class ContactUserEmailBodyOptions { + message: string; + subject: string; +} + +class ContactAdminEmailBodyOptions { + subject: string; + message: string; + firstName: string; + lastName: string; + email: string; +} \ No newline at end of file diff --git a/src/email/email.controller.ts b/src/email/email.controller.ts index b7a3ce17cd4ba8f75005b04c0e89d3bbea2f4665..a8aedee28aaa4a9a3127aa76c659a6033d3427da 100644 --- a/src/email/email.controller.ts +++ b/src/email/email.controller.ts @@ -1,5 +1,5 @@ -import { Controller, Post, Body, Res, HttpException, InternalServerErrorException, Logger, HttpCode } from '@nestjs/common'; -import { ContactForm, Email, EmailWithtoutFrom } from './email'; +import { Controller, Post, Body, InternalServerErrorException, Logger, HttpCode } from '@nestjs/common'; +import { ContactForm, EmailWithoutFrom } from './email'; import { EmailService } from './email.service'; import { ApiBadRequestResponse, ApiOkResponse, ApiUseTags, ApiOperation, ApiInternalServerErrorResponse } from '@nestjs/swagger'; @@ -12,14 +12,15 @@ export class EmailController { ) {} @Post('contact') - @ApiOperation({ title: 'Send email to admin (emails defined as var env of the project, see docker-compose.yml file).' }) + // tslint:disable-next-line:max-line-length + @ApiOperation({ title: 'Send email to admin (emails defined as var env of the project, see docker-compose.yml file) and recap email to user email.' }) @ApiOkResponse({ description: 'OK' }) @ApiBadRequestResponse({ description: 'Missing fields' }) @ApiInternalServerErrorResponse({ description: 'Internal error, this is probably a rabbitMQ related error (unreachable service...)'}) @HttpCode(200) async create(@Body() contactForm: ContactForm) { try { - return await this.emailService.sendToAdmin(contactForm); + return await this.emailService.sendContactEmails(contactForm); } catch (error) { Logger.log(error); throw new InternalServerErrorException(); @@ -32,7 +33,7 @@ export class EmailController { @ApiBadRequestResponse({ description: 'Missing fields' }) @ApiInternalServerErrorResponse({ description: 'Internal error, this is probably a rabbitMQ related error (unreachable service...)'}) @HttpCode(200) - async createEmail(@Body() email: EmailWithtoutFrom) { + async createEmail(@Body() email: EmailWithoutFrom) { try { return await this.emailService.send(email); } catch (error) { diff --git a/src/email/email.service.ts b/src/email/email.service.ts index 448a69c71717fd2387f4ab0bf6da0c51e7461880..76c992326b6a63f2fc97e6606701e3414c7e24b4 100644 --- a/src/email/email.service.ts +++ b/src/email/email.service.ts @@ -1,7 +1,8 @@ -import { Injectable, Logger, InternalServerErrorException, BadRequestException } from '@nestjs/common'; +import { Injectable, Logger, InternalServerErrorException } from '@nestjs/common'; import * as amqp from 'amqplib'; -import { ContactForm, Email, EmailWithtoutFrom, EmailWithHtmlContent } from './email'; +import { ContactForm, Email, EmailWithoutFrom } from './email'; import { ConfigService } from 'configuration/config.service'; +import { buildContactAdminEmail, buildContactUserEmail } from 'email-templates/contact'; @Injectable() export class EmailService { @@ -11,76 +12,50 @@ export class EmailService { this.config = this.configService.config; } - async sendToAdmin(contactForm: ContactForm) { - let conn, ch; - // tslint:disable-next-line:max-line-length - const rabbitmqUrl = `amqp://${this.config.rabbitMQ.user}:${this.config.rabbitMQ.password}@${this.config.rabbitMQ.host}:${this.config.rabbitMQ.port}`; - const mailerQueue = this.config.mailerQueue; - - const email = new Email(); - email.from = `${contactForm.firstname} ${contactForm.lastname} ${contactForm.from}`; - email.to = this.config.plateformDataEmail; - email.subject = contactForm.subject; - email.text = contactForm.text; - - Logger.log('[-] send method'); - Logger.log(email); - - // Connect to rabbitmq - try { - conn = await amqp.connect(rabbitmqUrl); - } catch (error) { - Logger.error(' [x] Error connecting to RabbitMQ: ', JSON.stringify(error)); - throw new InternalServerErrorException('Could not connect to rabbitMQ.'); - } - - try { - // Create a communication channel - ch = await conn.createChannel(); - } catch (error) { - Logger.error(' [x] Error creating channel: ', JSON.stringify(error)); - throw new InternalServerErrorException('Could not create channel.'); - } - - // Stringify and bufferise message - const buffer = Buffer.from(JSON.stringify(email)); - - try { - await ch.assertQueue(mailerQueue, { durable: true }); - } catch (error) { - Logger.error(' [x] Error creating channel: ', JSON.stringify(error)); - throw new InternalServerErrorException('Could not assert channel.'); - } - - try { - await ch.sendToQueue(mailerQueue, buffer, { persistent: true }); - } catch (error) { - Logger.error(' [x] Error sending to queue: ', JSON.stringify(error)); - throw new InternalServerErrorException('Could not send to queue.'); - } - - Logger.log(`Sent to queue ${mailerQueue}: ${JSON.stringify(email)}`); - - setTimeout(() => { conn.close(); }, 500); + async sendContactEmails(contactForm: ContactForm) { + Logger.log('[-] sendContactEmails method'); + + // contactForm.text = contactForm.text.replace(/(?:\r\n|\r|\n)/g, '<br />'); + const adminEmailBody = buildContactAdminEmail({ + subject: contactForm.subject, + message: contactForm.text, + firstName: contactForm.firstname, + lastName: contactForm.lastname, + email: contactForm.email, + }); + const userEmailBody = buildContactUserEmail({ + subject: contactForm.subject, + message: contactForm.text, + }); + + const adminEmail = new EmailWithoutFrom(); + adminEmail.to = [this.config.plateformDataEmail]; + adminEmail.subject = contactForm.subject; + adminEmail.html = adminEmailBody; + + const userEmail = new EmailWithoutFrom(); + userEmail.to = [contactForm.email]; + userEmail.subject = contactForm.subject; + userEmail.html = userEmailBody; + + await this.send(adminEmail); + await this.send(userEmail); return; } - async send(emailInfo: EmailWithtoutFrom) { + async send(emailInfo: EmailWithoutFrom) { let conn, ch; // tslint:disable-next-line:max-line-length const rabbitmqUrl = `amqp://${this.config.rabbitMQ.user}:${this.config.rabbitMQ.password}@${this.config.rabbitMQ.host}:${this.config.rabbitMQ.port}`; const mailerQueue = this.config.mailerQueue; - Logger.log(this.config); - - const email = new EmailWithHtmlContent(); + let email = new Email(); email.from = this.config.plateformDataEmail; - email.to = emailInfo.to; - email.subject = emailInfo.subject; - email.html = emailInfo.html; + email = Object.assign(email, emailInfo); Logger.log('[-] send method'); + Logger.log(this.config); Logger.log(email); // Connect to rabbitmq diff --git a/src/email/email.ts b/src/email/email.ts index 959b970667c70152123daa04f8a647d0cb0028f3..cc8ace1360ce6f36b5de7f312d104a800208416e 100644 --- a/src/email/email.ts +++ b/src/email/email.ts @@ -6,7 +6,7 @@ export class ContactForm { @ApiModelProperty() @IsDefined() @IsEmail() - from: string; + email: string; @ApiModelProperty() @IsDefined() @@ -47,39 +47,13 @@ export class Email { @IsDefined() subject: string; - @ApiModelProperty() - @IsDefined() - text: string; - -} - -export class EmailWithHtmlContent { - - @ApiModelProperty() - @IsDefined() - to: string[]; - - @ApiModelProperty() - @IsDefined() - from: string; - - @ApiModelPropertyOptional() - cc: string[]; - - @ApiModelPropertyOptional() - bcc: string[]; - - @ApiModelProperty() - @IsDefined() - subject: string; - @ApiModelProperty() @IsDefined() html: string; } -export class EmailWithtoutFrom { +export class EmailWithoutFrom { @ApiModelProperty() @IsDefined()