Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a way to keep track of email addresses that were not sent #439

Open
brunoamaral opened this issue Nov 27, 2024 · 0 comments
Open

add a way to keep track of email addresses that were not sent #439

brunoamaral opened this issue Nov 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@brunoamaral
Copy link
Owner

Notes

def send_simple_message(self, to, subject, html, text, site, customsettings):
		sender = f'GregoryAI <gregory@mg.{site.domain}>'
		response = requests.post(
			settings.EMAIL_MAILGUN_API_URL,
			auth=("api", settings.EMAIL_MAILGUN_API),
			data={
				"from": sender,
				"to": to,
				"subject": subject,
				"text": text,
				"html": html
			}
		)
		return response

here we return the response

for email in subscribers_email_list:
				self.send_simple_message(
					to=email,
					subject='Weekly Summary',
					html=html_content,
					text=text_content,
					site=site,
					customsettings=customsettings
				)

here we don't do anything with that response

We can have something like this

not_sent = []
for email in subscribers_email_list:
				r = self.send_simple_message(
					to=email,
					subject='Weekly Summary',
					html=html_content,
					text=text_content,
					site=site,
					customsettings=customsettings
				)
                if r.statuscode != 200:
                    not_sent.append(email)
@brunoamaral brunoamaral added the enhancement New feature or request label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant