使用 esmtp 实现用命令行 发送邮件1. 配置
注意:passwordyoung@ubuntu:~$ cat esmtprc
# Config file for ESMTP sendmail
identity=[email protected]
hostname=smtp.gmail.com:587
username="[email protected]"
password="my password"
starttls=required# The SMTP host and service (port)
#hostname=localdomain:25# The user name
#username=# The password
#password=# Whether to use Starttls
#starttls=disabled# The certificate passphrase
#certificate_passphrase=# The Mail Delivery Agent
#mda=""
young@ubuntu:~$2. 邮件正文
注意 "To:"和 邮件正文最后的两个回车.young@ubuntu:~$ cat mailbody.txt
Subject: test
To: [email protected]
hello, world!
3. 命令行
注意:后台执行young@ubuntu:~$ esmtp -C ./esmtprc -v -X log < mailbody.txt &
[2] 4303
young@ubuntu:~$ Connected to MTA
StartTLS OK (128 bits)
young@ubuntu:~$ From [email protected]: 250 OK y42sm7182444wfd.10
To [email protected]: 250 OK y42sm7182444wfd.10
To [email protected]: 250 OK y42sm7182444wfd.10
Message data: .
Message sent: 250 OK 1292153405 y42sm7182444wfd.10
Disconnected to MTA[2]- Done esmtp -t [email protected] -C
./esmtprc -v -X log < mailbody.txt
young@ubuntu:~$4. 收到的邮件Return-Path: <[email protected]>
Received: from ubuntu ([124.235.241.225])
by mx.google.com with ESMTPS id b11sm7188528wff.9.2010.12.12.03.34.00
(version=TLSv1/SSLv3 cipher=RC4-MD5);
Sun, 12 Dec 2010 03:34:02 -0800 (PST)
Message-ID: <[email protected]>
Date: Sun, 12 Dec 2010 03:34:02 -0800 (PST)
From: [email protected]
Subject: test
To: [email protected]
hello, world!
Date: Sun, 12 Dec 2010 19:34:01 +0800
From: [email protected]
Message-Id: <1292153641.270233.4347@ubuntu>