Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[HS] Bash - Envoyer des pièces jointes avec la commande mail en console

6 réponses
Avatar
Comendatore
Bonjour =E0 tous,
J'aimerais savoir si quelqu'un conna=EEt un moyen d'envoyer des pi=E8ces jo=
intes=20
dans un courriel avec la commande mail en bash.
Google n'a pas =E9t=E9 mon ami sur ce point l=E0, man non plus.

Comendatore.

6 réponses

Avatar
Patrice Karatchentzeff
2005/11/12, Comendatore :
Bonjour à tous,
J'aimerais savoir si quelqu'un connaît un moyen d'envoyer des pièces jointes
dans un courriel avec la commande mail en bash.
Google n'a pas été mon ami sur ce point là, man non plus.



mail ne sait pas faire grand chose...

1) soit tu fais cela à la main de zéro en bash (i.e. tu uencodes le
fichier, etc.)

2) soit tu utilises un langage de script puissant (genre perl) qui le
fera pour toi

3) tu vire mail et tu utilises mutt en ligne de commande qui le fera
aussi pour toi

LA dernière solution est de loin la plus rapide à mettre en œuvre...

PK

--
| _,,,---,,_ Patrice KARATCHENTZEFF
ZZZzz /,`.-'`' -. ;-;;,_ mailto:
|,4- ) )-,_. , ( `'-' http://p.karatchentzeff.free.fr
'---''(_/--' `-'_)
Avatar
fabrice régnier
Salut,

3 moyens simples pour attacher des fichiers:
uuencode
mutt
metamail (non testé)

par exemple avec mutt, ça donne
echo | mutt -s "objet du mail" -a "fichier attache" email_du_destinatai

Mais tu me dis: c'était pas ma question, je veux utiliser mail.

Bon, je trouve que c'est un peu plus compliqué, mais bon: L'idée est de
construire un fichier temporaire temp que tu réinjecte en entrée de
sendmail.

echo "Subject: le_sujet_du_mail_ici" > temp
echo "MIME-Version: 1.0" >> temp
echo "Content-Type: multipart/mixed; boundary= "CEQUEJEVEUX"" >> temp
echo "--CEQUEJEVEUX" >> temp
echo "Content-Type: text/plain; charset=ISO-8859-15; format=flowed"
>> temp
echo "Content-Transfer-Encoding: 8bit" >> temp
echo ""
echo "le corps de ton message" >> temp
echo "" >> temp
echo "--CEQUEJEVEUX" >> temp
echo "Content-Type: text/plain; charset=ISO-8859-15" >> temp
echo "Content-Transfer-Encoding: 8bit" >> temp
echo "Content-Disposition: attachment; filename=
"nom_du_fichier_attaché"" >> temp

#fichier attaché
cat $FILE_DEST >> temp

#et c'est parti!
/usr/sbin/sendmail < temp

rm temp -f

Il doit y avoir encore plein d'autres façons de procéder.
En espérant t'avoir aider.

f.

Comendatore a écrit :
Bonjour à tous,
J'aimerais savoir si quelqu'un connaît un moyen d'envoyer des pièces jointes
dans un courriel avec la commande mail en bash.
Google n'a pas été mon ami sur ce point là, man non plus.

Comendatore.




--
Pensez à lire la FAQ de la liste avant de poser une question :
http://wiki.debian.net/?DebianFrench

Pensez à rajouter le mot ``spam'' dans vos champs "From" et "Reply-To:"

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Avatar
Daniel Caillibaud
Comendatore a écrit :
Bonjour à tous,
J'aimerais savoir si quelqu'un connaît un moyen d'envoyer des pièces jointes
dans un courriel avec la commande mail en bash.
Google n'a pas été mon ami sur ce point là, man non plus.



???

http://www.google.fr/search?q=join+file+mail+shell

ou en français
http://www.mozbot.fr/search?q=mail+fichier+joint+shell
http://www.mozbot.fr/search?q=mail+uuencode+shell

uuencode fichier_local nom_fichier_attache_dans_le_mail | mail -s sujet


devrait marcher

Daniel


Comendatore.







--
Pensez à lire la FAQ de la liste avant de poser une question :
http://wiki.debian.net/?DebianFrench

Pensez à rajouter le mot ``spam'' dans vos champs "From" et "Reply-To:"

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Avatar
Igor Genibel
--ZfOjI3PrQbgiZnxM
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Comendatore [2005-11-12 13:12:15 +0100]:

Bonjour à tous,
J'aimerais savoir si quelqu'un connaît un moyen d'envoyer des pièces jointes
dans un courriel avec la commande mail en bash.
Google n'a pas été mon ami sur ce point là, man non plus.



:~ ->apt-cache search attachment bash
biabam - bash attachment mailer

:~ ->biabam mon_fichier | mail -s 'Mon sujet'

Voilà :)
--
Igor Genibel
«Non bene pro toto libertas venditur auro»
Freedom is not sold for all the gold in the world.
Dubrovnik motto

--ZfOjI3PrQbgiZnxM
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQBDewxG+xgdMBZI9sgRAjh7AJ4gFyrUpfWBQqCZzUBCaxONgsV4hACfb2NW
Ayts+wCzUoYv+Ap7hqMtQ/w =w7ak
-----END PGP SIGNATURE-----

--ZfOjI3PrQbgiZnxM--


--
Pensez à lire la FAQ de la liste avant de poser une question :
http://wiki.debian.net/?DebianFrench

Pensez à rajouter le mot ``spam'' dans vos champs "From" et "Reply-To:"

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Avatar
Guy
Le samedi 12 novembre 2005 à 13:12 +0100, Comendatore a écrit :
Bonjour à tous,
J'aimerais savoir si quelqu'un connaît un moyen d'envoyer des pièces jointes
dans un courriel avec la commande mail en bash.
Google n'a pas été mon ami sur ce point là, man non plus.

Comendatore.



Amusant, j'ai écrit cela hier soir...
si cela peut t'intéresser


faire avant :
"apt-get install mpack"


Voilà mon fichier envoi tout

"cat envoitout.sh"
######################
log=e-mail_fichiers.log
echo destinataire
read dest
echo sujet
read sujet
echo quel fichier [ *.mp3 *.zip ]
read files
# comptes
n=$(( 0 ))
for fichier in $files
do
n=$(( $n + 1))
echo $n : $fichier
done

echo ok ?
read

i=$(( 0 ))
for fichier in $files
do
i=$(( $i + 1))
mpack -s "[transfert $i/$n de $sujet ] ${fichier}" "$fichier" "$dest"
echo "mpack -s "[transfert $i/$n de $sujet ] ${fichier}]" "$fichier
" "$dest" "
date >> $log
echo "mpack -s "[transfert $i/$n de $sujet ] ${fichier}]" "$fichier
" "$dest" " >> $log
echo >> $log
done
Avatar
Bruno COSTA
ou plus simple moi je fais comme ca : )

uuencode ta-piece-jointe.txt ta-piece-jointe.txt | mail -s "ton sujet"



Bruno


----- Original Message -----
From: "Guy"
To: "Comendatore"
Cc:
Sent: Wednesday, November 16, 2005 1:25 PM
Subject: Re: [HS] Bash - Envoyer des pièces jointes avecla commande mail en
console


Le samedi 12 novembre 2005 à 13:12 +0100, Comendatore a écrit :
Bonjour à tous,
J'aimerais savoir si quelqu'un connaît un moyen d'envoyer des pièces
jointes
dans un courriel avec la commande mail en bash.
Google n'a pas été mon ami sur ce point là, man non plus.

Comendatore.



Amusant, j'ai écrit cela hier soir...
si cela peut t'intéresser


faire avant :
"apt-get install mpack"


Voilà mon fichier envoi tout

"cat envoitout.sh"
######################
log=e-mail_fichiers.log
echo destinataire
read dest
echo sujet
read sujet
echo quel fichier [ *.mp3 *.zip ]
read files
# comptes
n=$(( 0 ))
for fichier in $files
do
n=$(( $n + 1))
echo $n : $fichier
done

echo ok ?
read

i=$(( 0 ))
for fichier in $files
do
i=$(( $i + 1))
mpack -s "[transfert $i/$n de $sujet ] ${fichier}" "$fichier" "$dest"
echo "mpack -s "[transfert $i/$n de $sujet ] ${fichier}]" "$fichier
" "$dest" "
date >> $log
echo "mpack -s "[transfert $i/$n de $sujet ] ${fichier}]" "$fichier
" "$dest" " >> $log
echo >> $log
done



--
Pensez à lire la FAQ de la liste avant de poser une question :
http://wiki.debian.net/?DebianFrench

Pensez à rajouter le mot ``spam'' dans vos champs "From" et "Reply-To:"

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact