SMTP - Perl

更新时间:
复制 MD 格式

Send email through Direct Mail's SMTP service using Swaks, a Perl-based command-line SMTP testing tool.

Prerequisites

Before you begin, ensure that you have:

  • A verified sender address in Direct Mail

  • The SMTP password for your sender address

  • A Debian/Ubuntu system with curl and sudo access

Send an email

Swaks (Swiss Army Knife for SMTP) is a Perl-based command-line tool for testing SMTP. The steps below install Swaks and use it to send an email over Direct Mail's SMTP service.

  1. Download Swaks.

   curl http://www.jetmore.org/john/code/swaks/files/swaks-20130209.0/swaks -o swaks
  1. Make the script executable.

   chmod +x swaks
  1. Install Perl.

   sudo apt-get -y install perl
  1. Send an email. Replace the placeholder values before running the command.

       ./swaks --auth \
               --server smtpdm.aliyun.com \
               --au <sender-address> \
               --ap <smtp-password> \
               --from <sender-address> \
               --to <recipient-address> \
               --h-Subject: "Hello" \
               --body 'Testing mail!'

Replace the following placeholders:

  • <sender-address> after --au: your verified sender address in Direct Mail.

  • <smtp-password> after --ap: the SMTP password for your sender address.

  • <sender-address> after --from: the sender address (same as --au).

  • <recipient-address> after --to: the recipient's email address.