Reputation: 797
I have a PowerShell script that runs a report on an SQL database and attaches the report to an email sent using send-mailmessage
.
My syntax is send-mailmessage -to [email protected] -cc [email protected] -subject "PE matter report (Since 1 July 2015)" -bodyashtml -body $body -Attachments "C:\scripts-and-reports\New PE matters since 01 July 2015.xlsx" -from [email protected] -Priority high -Verbose -SmtpServer domain-com-au.mail.protection.outlook.com
.
It returns an error
send-mailmessage : Insufficient system storage. The server response was: 4.5.3 Too many recipients (AS780090)
[AM1FFO11FD023.protection.gbl]
If I remove the Cc from the script, the message sends OK and is received OK. But I kind of need the Cc in there and if possible, a Bcc as well.
I have added the server's WAN IP to my domain's SPF record (and it tests OK), I have added the URL to Office365's ExchangeOnline Connection Filter Allowed list, and I have even added a transport rule checking the IP which sets SCL to -1 and bypasses clutter.
I just can't figure this out. Does anyone have any suggestions?
Upvotes: 1
Views: 3766
Reputation: 797
I think I found a workaround...
I've switched to using the Office365 SMTP server with authentication and SSL.
The new command is:-
$login = "[email protected]"
$password = "abovemailboxpassword" | Convertto-SecureString -AsPlainText -Force
$credentials = New-Object System.Management.Automation.Pscredential -Argumentlist $login,$password
send-mailmessage -to [email protected] -cc [email protected] -subject "PE matter report (Since 1 July 2015)" -bodyashtml -body $body -Attachments "C:\scripts-and-reports\New PE matters since 01 July 2015.xlsx" -from [email protected] -Priority high -Verbose -UseSsl -Port 587 -SmtpServer smtp.office365.com -Credential $credentials
I think this is less secure because the password is stored in plain text, but all of the servers are sitting behind a firewall and aren't used by anyone else.
I hadn't thought of doing it this way - but at least it is working for -to
, -cc
and -bcc
all at the same time.
Upvotes: 1
Reputation: 17345
This is more of a possibilities that could be tried than a definite answer.
A question first: Are the [email protected] and/or [email protected] distribution lists? If yes, try it with single user addresses.
Maybe you are hitting somehow the throttling limit - which you can find here. To quote the support page - the throttling limit for STMP client submission. The limit is:
10,000 recipients per day. 30 messages per minute
(As Bacon Bits has written you may have some internal limit on top of this one)
You have to be bellow this limit. You are probably hitting the limit with the -cc
.
To enclose the mail address/lists with double quotes
send-mailmessage -to "[email protected]" -cc "[email protected]" ...
Does it work for with -bcc
excluding the -cc
?
Is -cc
optional or always filled?
Upvotes: 1