0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PowerShellスクリプトファイル(.ps1)を使ってSMTPDevメールサーバにメールを送信する方法

Posted at

PowerShellスクリプトファイルを使てSMTPDevへメールを送信する方法を解説します。

Windows PowerShell ISE(Integrated Scripting Environment)の起動方法

1.スタートメニューを開き、「PowerShell ISE」と検索します。
image.png
2.「PowerShell ISE」をクリックすると下記の画面が表示されます。スクリプトの新規作成(赤枠部)をクリックします。
image.png
3.スクリプトエディターが表れるので、こちらにメール送信のスクリプトを記載します。
image.png

PowerShellスクリプトファイル(.ps1)の書き方

下記のスクリプトのようにメール送信処理を記載します。

sample.ps1
Send-MailMessage `
    -From "test@example.com" `
    -To "recipient@example.com" `
    -Subject "SMTPDevテストメール" `
    -Body "これはSMTPDev経由で送られたテストメールです。" `
    -SmtpServer "localhost" `
    -Port 1025

そして、実行ボタン(赤枠部)をクリックすればSMTPDevにデータが送信されます。
image.png

SMTPDevのメッセージ画面を見ると、確かにメールが送信されています。
image.png

サイト

Power Shellスクリプトに関する情報

SMTPDevの環境構築に関する情報

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?