Reputation: 141
I'm trying to develop a mass email script by yagmail. My script works properly but what I want is to showing only the receiving recipient's Email in the 'To' field and not all others. E.g. If I send Emails to [email protected] and [email protected], example1 should see [email protected] and example2 should see [email protected] in the 'To' field.
Is there a way to achieve this? Or maybe do I have to use loop over each recipient with send_mail?
Here's my script
import yagmail
with open("folder/email.txt") as f:
recipients = f.read()
yag = yagmail.SMTP('my.username')
email_subject = 'A subject'
embedded_image = yagmail.inline("folder/image.png")
message1 = '<p>lorem impsum lorem ipsum</p>'
message2 = '<p>lorem impsum lorem ipsum</p>'
attachment1 = 'folder/image.png'
attachment2 = 'folder/file.pdf'
yag.send(to = recipients, subject = email_subject, contents = [message1, embedded_image, message2, attachment1, attachment2])
Upvotes: 0
Views: 190
Reputation: 189497
Indeed, there is no way for a single message to have different headers for different recipients. You have to loop over recipients and send a separate message to each.
A possible alternative might be to use bcc
and perhaps put yourself as the explicit to
recipient.
Upvotes: 1