sh Envoi demailchiffrés

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Envoi demailchiffrés相关的知识,希望对你有一定的参考价值。

Source : https://pastebin.franceserv.fr/1348
#!/bin/bash
 
# --- Variables definition ---------------------------------------
 
from='noreply@example.com'
from_name='Example Compagny'
to='example@example.com'
to_name='Example Name'
subject='Test mail PGP'
boundary1=$(openssl rand -hex 24)
boundary2=$(openssl rand -hex 24)
boundary3=$(openssl rand -hex 24)
recipient_id='***key_id***'
 
# --- Message ----------------------------------------------------
 
message="This is a simple test message which should be encrypted."
 
# --- message format to text/html mode part ---------------------------
 
body_text=$(echo "Content-Type: multipart/mixed; boundary=\"$boundary2\"
 
This is a multi-part message in MIME format.
--$boundary2
Content-Type: multipart/alternative; boundary=\"$boundary3\"
 
--$boundary3
Content-Type: text/plain; charset=utf-8
 
(TEXT mode) Bonjour $to_name,
 
$message
 
Cordialement,
$from_name
 
--$boundary3
Content-Type: text/html; charset=utf-8
Content-Language: fr
Content-Transfer-Encoding: quoted-printable
 
<html>
<body>
<p>
(HTML mode) Bonjour $to_name,
</p><p>
$message
</p><p>
Cordialement,<br/>
$from_name
</p>
</body>
</html>
 
--$boundary3--
 
--$boundary2--" | gpg2 --always-trust -ea -r $recipient_id)
 
# --- mail format global -----------------------------------------
 
echo "Return-Path: $from
From: $from_name <$from>
Reply-To: contact@example.com
To: $to
Subject: $subject
MIME-Version: 1.0
Content-Type: multipart/encrypted; protocol=application/pgp-encrypted; boundary=\"$boundary1\"
 
This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
--$boundary1
Content-Type: application/pgp-encrypted
Content-Description: PGP/MIME version identification
 
Version: 1
 
--$boundary1
Content-Type: application/octet-stream; name="encrypted.asc"
Content-Description: OpenPGP encrypted message
Content-Disposition: inline; filename="encrypted.asc"
 
$body_text
 
--$boundary1--" | /usr/sbin/sendmail -t -oi -f$from
#!/bin/bash

# --- Variables definition ---------------------------------------

from='noreply@example.com'
from_name='Example Compagny'
to='example@example.com'
to_name='Example Name'
subject='Test mail PGP'
boundary1=$(openssl rand -hex 24)
boundary2=$(openssl rand -hex 24)
boundary3=$(openssl rand -hex 24)
recipient_id='***key_id***'

# --- Message ----------------------------------------------------

message="This is a simple test message which should be encrypted."

# --- message format to text/html mode part ---------------------------

body_text=$(echo "Content-Type: multipart/mixed; boundary=\"$boundary2\"

This is a multi-part message in MIME format.
--$boundary2
Content-Type: multipart/alternative; boundary=\"$boundary3\"

--$boundary3
Content-Type: text/plain; charset=utf-8

(TEXT mode) Bonjour $to_name,

$message

Cordialement,
$from_name

--$boundary3
Content-Type: text/html; charset=utf-8
Content-Language: fr
Content-Transfer-Encoding: quoted-printable

<html>
<body>
<p>
(HTML mode) Bonjour $to_name,
</p><p>
$message
</p><p>
Cordialement,<br/>
$from_name
</p>
</body>
</html>

--$boundary3--

--$boundary2--" | gpg2 --always-trust -ea -r $recipient_id)

# --- mail format global -----------------------------------------

echo "Return-Path: $from
From: $from_name <$from>
Reply-To: contact@example.com
To: $to
Subject: $subject
MIME-Version: 1.0
Content-Type: multipart/encrypted; protocol=application/pgp-encrypted; boundary=\"$boundary1\"

This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
--$boundary1
Content-Type: application/pgp-encrypted
Content-Description: PGP/MIME version identification

Version: 1

--$boundary1
Content-Type: application/octet-stream; name="encrypted.asc"
Content-Description: OpenPGP encrypted message
Content-Disposition: inline; filename="encrypted.asc"

$body_text

--$boundary1--" | /usr/sbin/sendmail -t -oi -f$from

以上是关于sh Envoi demailchiffrés的主要内容,如果未能解决你的问题,请参考以下文章

sh 在fedora(23 +)上安装node.js.(v5.0.0)

23.dubbo脚本之stop.sh

sh http://qiita.com/kumagi/items/23db1b7b564db27b53e6

kafka 命令

替换 sh 中的源

CronJob 没有运行