You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package types
import (
"os"
"github.com/nikoksr/notify"
awsSes "github.com/nikoksr/notify/service/amazonses"
)
// CustomNotifier holds the notify instance and any services we've set up.
type CustomNotifier struct {
notifier *notify.Notify
sesService *awsSes.AmazonSES
// ... other services
}
// NewCustomNotifier creates a new CustomNotifier with all services initialized.
func NewCustomNotifier() (*CustomNotifier, error) {
// Initialize the notify instance
n := notify.New()
var senderAddress string
// Initialize all services here (like sesService, discordService, etc.)
// For AWS SES
sesSvc, err := awsSes.New(
os.Getenv("AWS_MAIL_ACCESS_KEY"),
os.Getenv("AWS_MAIL_SECRET_KEY"),
os.Getenv("AWS_MAIL_REGION"),
senderAddress,
)
if err != nil {
return nil, err // Handle the error if SES service fails to initialize
}
// ... initialize other services
// Return a new CustomNotifier
return &CustomNotifier{
notifier: n,
sesService: sesSvc,
// ... other services
}, nil
}
// SendWithSES sends a notification via AWS SES.
func (cn *CustomNotifier) SendWithSES(s *FiberServer, receivers, subject, message string) error {
cn.notifier.UseServices(cn.sesService)
cn.sesService.AddReceivers(receivers)
return cn.notifier.Send(s.Ctx, subject, message)
}
How can I make the final parameter, senderAddress, dynamic in this code?
My use case is i may use noreply@"+os.Getenv("DOMAIN_NAME") or support@"+os.Getenv("DOMAIN_NAME")
The text was updated successfully, but these errors were encountered:
Code Implement
How can I make the final parameter,
senderAddress
, dynamic in this code?My use case is i may use
noreply@"+os.Getenv("DOMAIN_NAME")
orsupport@"+os.Getenv("DOMAIN_NAME")
The text was updated successfully, but these errors were encountered: