I write one Script for add members to a Google Group. The data is write into my website, saved into Google Sheets and this sheet launch the script for add the member to the group.
The code is working fine, but only in some cases. Generally, the adresses with @hotmail
are rejected with this message:
errorException: The email is invalid
I think there is one problem with @hotmail and another adresses. I migrated one list from Mailchimp to Google Groups with the same process, and multiple email adresses from @hotmail were rejected.
These email adresses not are invalid, the reports at Mailchimp indicated that the messages to those addresses were delivered.
In the past week alone, about five @hotmail addresses were rejected. They were real people trying to subscribe to my list, including people I have had communication with using those @hotmail email addresses. So I'm sure there is a problem in Google Workspace regarding @hotmail addresses. The same happens with a lot of addresses with @outlook, and with adresses of some custom domains.
How I can solve this.
The code I'm using is here:
function addUsertoGroup(userEmail) {
var userEmail = userEmail.toLowerCase();
var groupId = "My-Group@example.com";
var group = GroupsApp.getGroupByEmail(groupId);
try {
var hasMember = group.hasUser(userEmail);
if (!hasMember){
var newMember = {email: userEmail, role: "MEMBER"};
var mStatus=AdminDirectory.Members.insert(newMember, groupId);
Logger.log(" inserted: "+mStatus.email+"\n");
return true;
}else{
Logger.log(userEmail+" exists\n");
return false;
}
} catch(e) {
Logger.log(userEmail + " error"+e+"\n");
return false;
}
}
This is one error example in the Log: