@@ -406,6 +406,92 @@ const pwdreset_template = `
406406</body>
407407</html>`
408408
409+ const completedreset_template = `
410+ <!DOCTYPE html>
411+ <html>
412+ <head>
413+ <style>
414+ body {
415+ font-family: Arial, sans-serif;
416+ line-height: 1.6;
417+ color: #333;
418+ max-width: 600px;
419+ margin: 0 auto;
420+ }
421+ .header {
422+ background-color: #f8f9fa;
423+ padding: 20px;
424+ border-bottom: 2px solid #007bff;
425+ text-align: center;
426+ }
427+ .logo {
428+ max-width: 200px;
429+ margin-bottom: 10px;
430+ }
431+ .content {
432+ padding: 0 20px 20px 20px;
433+ }
434+ .button {
435+ background-color: #007bff;
436+ color: white;
437+ padding: 12px 24px;
438+ text-decoration: none;
439+ border-radius: 4px;
440+ font-weight: bold;
441+ display: inline-block;
442+ margin: 20px 0;
443+ }
444+ .button:hover {
445+ background-color: #0069d9;
446+ }
447+ .important-note {
448+ background-color: #f8f9fa;
449+ border-left: 4px solid #ffc107;
450+ padding: 15px;
451+ margin: 15px 0;
452+ font-size: 0.9em;
453+ }
454+ .footer {
455+ margin-top: 30px;
456+ padding-top: 15px;
457+ border-top: 1px solid #eee;
458+ font-size: 0.9em;
459+ color: #777;
460+ text-align: center;
461+ }
462+ .contact-info {
463+ margin-top: 20px;
464+ }
465+ </style>
466+ </head>
467+ <body>
468+ <div class="header">
469+ <h2>Password Changed</h2>
470+ </div>
471+
472+ <div class="content">
473+
474+
475+ <p>You have successfully changed your password for Rent Management System.</p>
476+ <p>If this wasn't done by you, please immediately reset the password of your Rent Management System.</p>
477+
478+ <div class="contact-info">
479+ <p>If you have any questions or need assistance, please contact our support team:</p>
480+ <p>Email: <a href="mailto:[email protected] ">[email protected] </a><br> 481+ Phone: 0654051622</p>
482+ </div>
483+
484+ <p>Best regards,</p>
485+ <p>The Rent Management System Team</p>
486+
487+ <div class="footer">
488+ <p><a href="https://www.rent.ragodevs.com">www.rent.ragodevs.com</a></p>
489+ <p>© 2025 Rent Management System. All rights reserved.</p>
490+ </div>
491+ </div>
492+ </body>
493+ </html>`
494+
409495func enableCORS () gin.HandlerFunc {
410496
411497 corsConfig := cors .DefaultConfig ()
@@ -538,6 +624,32 @@ func (mc *MailConfig) sendPasswordResetEmail(data ActivateOrResetData) error {
538624 return nil
539625}
540626
627+ func (mc * MailConfig ) sendResetCompletedEmail (data ActivateOrResetData ) error {
628+
629+ tmpl , err := template .New ("email" ).Parse (completedreset_template )
630+ if err != nil {
631+ return fmt .Errorf ("failed to parse email template: %v" , err )
632+ }
633+
634+ var emailBody bytes.Buffer
635+ if err := tmpl .Execute (& emailBody , data ); err != nil {
636+ return fmt .Errorf ("failed to execute email template: %v" , err )
637+ }
638+
639+ recipients := []string {data .Email }
640+
641+ subject := "Password Changed for Rent Management System"
642+ msg := fmt .Sprintf ("Subject: %s\n To: %s\n Content-Type: text/html\n \n %s" , subject , data .Email , emailBody .String ())
643+
644+ auth := smtp .PlainAuth ("" , mc .USER , mc .PWD , mc .HOST )
645+ err = smtp .SendMail (mc .HOST + ":" + mc .PORT , auth , mc .USER , recipients , []byte (msg ))
646+ if err != nil {
647+ return fmt .Errorf ("failed to send email: %v" , err )
648+ }
649+
650+ return nil
651+ }
652+
541653func main () {
542654
543655 mc := & MailConfig {}
@@ -623,6 +735,23 @@ func main() {
623735 c .JSON (200 , gin.H {"message" : "Email sent successfully!" })
624736 })
625737
738+ router .POST ("/rent-completedpwdreset" , func (c * gin.Context ) {
739+
740+ var data ActivateOrResetData
741+ if err := c .ShouldBindJSON (& data ); err != nil {
742+ c .JSON (400 , gin.H {"error" : err .Error ()})
743+ return
744+ }
745+
746+ if err := mc .sendResetCompletedEmail (data ); err != nil {
747+ log .Printf ("Error sending email: %v" , err )
748+ c .JSON (500 , gin.H {"error" : "Failed to send email" })
749+ return
750+ }
751+
752+ c .JSON (200 , gin.H {"message" : "Email sent successfully!" })
753+ })
754+
626755 port := os .Getenv ("PORT" )
627756 if port == "" {
628757 port = "8080"
0 commit comments