mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 22:41:03 +00:00 
			
		
		
		
	**Backport:** https://codeberg.org/forgejo/forgejo/pulls/7337 - Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Co-authored-by: Gusted <postmaster@gusted.xyz> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7354 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
		
			
				
	
	
		
			33 lines
		
	
	
	
		
			848 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			848 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2020 The Gitea Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package private
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"forgejo.org/modules/setting"
 | |
| )
 | |
| 
 | |
| // Email structure holds a data for sending general emails
 | |
| type Email struct {
 | |
| 	Subject string
 | |
| 	Message string
 | |
| 	To      []string
 | |
| }
 | |
| 
 | |
| // SendEmail calls the internal SendEmail function
 | |
| // It accepts a list of usernames.
 | |
| // If DB contains these users it will send the email to them.
 | |
| // If to list == nil, it's supposed to send emails to every user present in DB
 | |
| func SendEmail(ctx context.Context, subject, message string, to []string) (*ResponseText, ResponseExtra) {
 | |
| 	reqURL := setting.LocalURL + "api/internal/mail/send"
 | |
| 
 | |
| 	req := newInternalRequest(ctx, reqURL, "POST", Email{
 | |
| 		Subject: subject,
 | |
| 		Message: message,
 | |
| 		To:      to,
 | |
| 	})
 | |
| 
 | |
| 	return requestJSONResp(req, &ResponseText{})
 | |
| }
 |