Except PowerShell Send-MailMessage cmdlet, This is a Windows batch file solution.
Send telnet email from .bat
Hi dear colleagues,
i try to send an email from cmd but i would like to script in a bat file:
telnet mail.internal.ent.com 25
mail from:@ent.com
RCPT TO:@ent.com
data
Subject:Test
.
but i dont know how, so please could anybody help me?
Thanks in advance and BR!!!
-
Xiaopo Yang - MSFT 12,726 Reputation points Microsoft Vendor
2021-07-01T02:26:45.717+00:00
3 additional answers
Sort by: Most helpful
-
Castorix31 86,881 Reputation points
2021-06-30T12:56:47.047+00:00 You can use a PowerShell script
How to Send an Email Using Windows PowerShell
or a VBS script
Add Send Email to any VBscript -
Sam of Simple Samples 5,546 Reputation points
2021-06-30T18:12:53.79+00:00 After executing telnet, input is read by telnet, not by the command prompt. So in other words the commands you show after telnet would not be read from the bat file. So try putting the following in a separate file (for example
mail.txt
):mail from:******@ent.com RCPT TO:******@ent.com data Subject:Test .
Be sure to put a quit command at the end. Then execute the following:
telnet mail.internal.ent.com 25<mail.txt
Except mail.txt would be the entire path and filename; you might need to use double quotes around the path and filename.
I consider that to be a cumbersome way to do it. I suggest using something else, as in the answer from Castorix31. But if you must use a command prompt then the preceding should work.
-
powerswitch 41 Reputation points
2021-07-01T07:36:46.257+00:00 Thanks to all for your answers and BR!!!!!