andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 169 forks source link

Send Email to Multiple Recipients #155

Closed ugookoro closed 8 years ago

ugookoro commented 8 years ago

Hi. I'm trying to send emails to multiple recipients in my code. The email addresses of these recipients are saved in a List<string> object which is saved in the model that my email view uses. the problem is it always breaks. here's my implementation `@using Entities.Models.Mailer; @using System.Web.Mvc; @model SharerInterestNotificationEmail @{ var recipients =""; foreach (var item in Model.Recipients) // Model.Recipients is a list of email addresses. { recipients += item + " "; }

}

To: @recipients From: @Model.Sender Subject: Interest Content-Type: text/html; charset=utf-8

html here

` The error is get is "an invalid character was found in the mail header ' ,'" is there a way to send emails to multiple recipients without using the CC or BCC headers.
ugookoro commented 8 years ago

I've fixed this. The error is get is "an invalid character was found in the mail header ',' i fixed this by removing the trailing comma at the end or my recipients string (Basically the recipients variable was returning "example@email.com, email@email.com," so i removed it by calling the String.TrimEnd([offending char here]).