|
Howdy. I'm running into a frustrating issue trying to send a simple SMTP message from a server in Powershell v1. Here's the relevant portion of the script; the attachment is present and the path is correct. (I've omitted some object dumps I've added in the course of troubleshooting for clarity.) code:
code:
What am I doing wrong?
|
# ¿ Dec 2, 2011 19:00 |
|
|
# ¿ May 17, 2024 01:53 |
|
adaz posted:You're not doing anything wrong by that code sample I stared at it for like 10 minutes and can't see anything wrong. I mean just copy pasting that code block gets me this: DisplayName is blank, User, Host and Address have the appropriate entries. If it helps narrow it down, this is 64-bit Server 2008 Enterprise SP2 with the Windows Powershell feature installed. I'm guessing we need either to install v2 or put in a later version of .NET (v2, 3, and 3.5 are currently installed). Hypnobeard fucked around with this message at 20:44 on Dec 2, 2011 |
# ¿ Dec 2, 2011 20:38 |
|
Jethro posted:How sure are you that you're running v1? I'm pretty sure 2008 SP2 has v2 already. Try looking at $psversiontable. If it exists, you're running v2. If not you are indeed on v1. $psversiontable doesn't exist (empty response). $Host.Version returns: code:
|
# ¿ Dec 2, 2011 21:27 |
|
adaz posted:Oh that's fine, displayname isn't a required attribute you don't need it to send email. For whatever reason with v1 it's not displaying address when you just check the $msg and output it to the shell but it should still send the actual email just fine. V2 looks like displays address by default or displayname if it's filled in. You can create a valid MailAddress with a displayname if you really care about how it shows up (http://msdn.microsoft.com/en-us/library/system.net.mail.mailaddress.aspx) I'm not too worried about the displayname; it's refusing to send the email period because of the lack of recipient. I guess the answer is upgrade to v2, which means it's time to start the approval process. Meh. Thank you very much for the help.
|
# ¿ Dec 2, 2011 21:47 |
|
adaz posted:Weird, it shouldn't care at all about display name. I was looking at some of my old code I know was created in the V1 days and I've never had to add a display name. So something like this won't work? It still whines about invalid recipient? There has to be something else going on here, in particular i'm wondering about that from part, it really shouldn't be displaying it like that from everything I remember, almost like it's html Grrr. Turns out the McAfee client on the server was set to block port 25 transactions. Fixing that resolved the problem. It's still weird that it doesn't show the recipient addresses on the MailMessage object, though. Again, thanks for the help.
|
# ¿ Dec 2, 2011 22:44 |