Try something like:
// initialize empty array on each click of a checkbox
var addressArray = [];
// find each checkbox that is checked
$("input[name='mailing-groups']:checked").each(function (index, el) {
var className = $(el).val();
// use the value of each checked checkbox to find the mailto elements with that class
$("."+className).each(function (mailindex, mailelement) {
addressArray.push($(mailelement).text());
});
});
// create a comma separated string from the array
var addresses = addressArray.join(",");