markdown 使用终端发送电子邮件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 使用终端发送电子邮件相关的知识,希望对你有一定的参考价值。

# Sending emails with powershell

Securely send emails with attachments
```posh
$credential = Get-Credential
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }

Send-MailMessage `
-SmtpServer 172.XXX.XXX.XXX `
-port 587 `
-UseSsl `
-Credential $credential `
-From "Nordine Ben Bachir <nordine@authorized.com>" `
-To "xxxxxx" `
-Bcc "xxxxxxxxxx"`
-Subject "Don t forget today s meeting!" `
-Body "Test email with Ssl (port58)7" 
-Attachments @(Get-ChildItem  "C:\nordinetest\" | % { $_.FullName })
```

# Swiss Army Knife for SMTP (swaks)

All attachment will have the mimetype *application/octet-stream*
```bash
$ swaks -s "${smtpserver}" -p "${smtpport}" -t "$to" -f "$from" --header "Subject: $subject" -S \
      --protocol ESMTP -a -au "$user" -ap "$password" --body "$body" \
      --attach foo.pdf  --attach bar.jpg
```

Or manually specifiy MIME type
```bash
$ swaks -s "${smtpserver}" -p "${smtpport}" -t "$to" -f "$from" --header "Subject: $subject" -S \
      --protocol ESMTP -a -au "$user" -ap "$password" --body "$body" \
      --attach-type "$(get_mimetype foo.pdf)" --attach foo.pdf \
      --attach-type "$(get_mimetype bar.jpg)" --attach bar.jpg
```
the mimetype MUST be before the file name.

# ToDo

+ To do SSL/TLS, see the various --tls* options

以上是关于markdown 使用终端发送电子邮件的主要内容,如果未能解决你的问题,请参考以下文章

通过outlook发送R Markdown输出作为正文电子邮件(RDCOMclient)

markdown 发送电子邮件

openshift 电子邮件从终端发送,但不是从 php

markdown 从Linux命令行发送电子邮件(postfix或netcat)

markdown 机器人发送邮件

markdown 测试PHP能够发送邮件