kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.64k stars 263 forks source link

Support for Gmail aliases #105

Open metalcamp opened 6 years ago

metalcamp commented 6 years ago

I have one particular usecase, where I would like to send from aliased account in Gmail. AFAIK yagmail supports only aliases in email {email_acc : 'User' } in SMTP login function, which changes only display name but not email.

Example: I login in Gmail with mike.d@gmail.com, but I would like to send email with mike@gmail.com.

Where should I look to implement this functionality? I was looking at yagmail/sender.py, function attempt send - is this the correct place?

def _attempt_send(self, recipients, msg_string): attempts = 0 while attempts < 3: try: result = self.smtp.sendmail(self.user, recipients, msg_string) self.log.info('Message sent to %s', recipients) self.num_mail_sent += 1 return result except smtplib.SMTPServerDisconnected as e: self.log.error(e) attempts += 1 time.sleep(attempts * 3) self.unsent.append((recipients, msg_string)) return False

leikoilja commented 4 years ago

I would also be grateful to see that implemented. For now will have to stick to a custom written client instead