Skip to content

Commit

Permalink
changed the type of sent message from string (msg_string) to bytes (m…
Browse files Browse the repository at this point in the history
…sg_bytes), because the dkim verification fails when string is used
  • Loading branch information
bityob committed Dec 19, 2021
1 parent 589cefa commit 54cd23f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions yagmail/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def prepare_send(
)

recipients = addresses["recipients"]
msg_string = msg.as_bytes()
return recipients, msg_string
msg_bytes = msg.as_bytes()
return recipients, msg_bytes

def send(
self,
Expand All @@ -154,7 +154,7 @@ def send(
):
""" Use this to send an email with gmail"""
self.login()
recipients, msg_string = self.prepare_send(
recipients, msg_bytes = self.prepare_send(
to,
subject,
contents,
Expand All @@ -167,14 +167,15 @@ def send(
group_messages,
)
if preview_only:
return (recipients, msg_string)
return self._attempt_send(recipients, msg_string)
return recipients, msg_bytes

def _attempt_send(self, recipients, msg_string):
return self._attempt_send(recipients, msg_bytes)

def _attempt_send(self, recipients, msg_bytes):
attempts = 0
while attempts < 3:
try:
result = self.smtp.sendmail(self.user, recipients, msg_string)
result = self.smtp.sendmail(self.user, recipients, msg_bytes)
self.log.info("Message sent to %s", recipients)
self.num_mail_sent += 1
return result
Expand Down

0 comments on commit 54cd23f

Please sign in to comment.