Sending Multiple Emails - Previous recipients remains in the following emails
See original GitHub issueHi,
I am sending multiple emails with MailGun in the foreach loop and every next email is adding previous email address as recipient 😦
I am using DI for _email.
await _email.To(emailAlert.Subscriber.Email)
.Subject("My Subject")
.Body(GetAlertBody(emailAlert), true)
.SendAsync();
I can see in the MailGun log this, headers has 2 emails (not correct) while the recipient only one which is correct.
"message": {
"headers": {
"to": "email1@company.co.uk, email2@gmail.com",
"subject": "My Subject"
},
"attachments": [],
"size": 1175
},
"recipient": "email2@gmail.com",
Also in the Fiddler Raw I can see this, there shouldn’t be email1@company.co.uk:
Host: api.mailgun.net
--1cf329c2-d30a-41d4-a1ec-8bce3a24fd60
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=from
Uptime Monitor <DoNotReply@mg.mydomain.com>
--1cf329c2-d30a-41d4-a1ec-8bce3a24fd60
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=to
<email1@company.co.uk>
--1cf329c2-d30a-41d4-a1ec-8bce3a24fd60
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=to
<email2@gmail.com>
--1cf329c2-d30a-41d4-a1ec-8bce3a24fd60
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=subject
My Subject
--1cf329c2-d30a-41d4-a1ec-8bce3a24fd60
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=html
Am I doing something incorrectly and SendAsync() just builds up somehow and doesn’t clear the recipient in the header?
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Outlook is sending multiple copies of an email
I'm having a problem with Outlook sending multiple copies of some emails - usually those with attachments.
Read more >How to copy all the email recipients from one email I have ...
Right click the drop down icon at the end of the email address in the sent email, Left click and highlight all email...
Read more >Your message did not reach some or all of the intended ...
Your message did not reach some or all of the intended recipients. I have three email addresses; two of which are Outlook. Since...
Read more >Mail merge
When a recipient replies, they'll be excluded from the remaining messages in the mail merge so you can respond to them personally. Follow-up...
Read more >E-mailing a large amount of recipients
If you have a large list of recipients you need to send an email you, you should never try sending one large email...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually think we should throw an exception if you try send the same email instance twice.
On Wed, 29 Jul 2020, 7:15 pm Luke Lowrey, lukenlowrey@gmail.com wrote:
This issue has just hit on on a production site with duplicate emails sent. Looking at the implementation for the To method I would have thought it safer to first clear the ToAddresses collection in the Data property - it might prevent chaining multiple calls to the To method but its hard to see why someone would do that and not simply pass a semicolon list or list of Address.