Portál AbcLinuxu, 5. května 2025 03:24
mail
poslat email na username@seznam.cz . Nevim jak to nastavit nebo jaké tam dát za to argumenty. Předem díky. Koukal jsem se do man
a do jiných diskuzí a jediné co jsem našel ta je toto:
open (MAIL, "|/usr/sbin/mail -t "); print MAIL "From: email@dom.cz\n"; print MAIL "To: email@dom.cz\n"; print MAIL "Content-Type: text/plain\n"; print MAIL "Subject: Pokus\n\n"; print MAIL "Zpravaa"; close (MAIL);A to mi nefunguje.
echo "Zpravaa" | mail -s Předmět emai@lov.ka
mail
?
P.S. Mam Gentoo
#!/usr/bin/env python def send_email(sender, recipient, subject, body, verbose = False, SMTPserver="localhost"): """Send an email. All arguments should be Unicode strings (plain ASCII works as well). Only the real name part of sender and recipient addresses may contain non-ASCII characters. The email will be properly MIME encoded and delivered though SMTP to localhost port 25. This is easy to change if you want something different. The charset of the email will be the first one out of US-ASCII, ISO-8859-1 and UTF-8 that can represent all the characters occurring in the email. """ from smtplib import SMTP from email.MIMEText import MIMEText from email.Header import Header from email.Utils import parseaddr, formataddr if not sender.startswith('From: '): sender += 'From: ' if not recipient.startswith('To: '): recipient += 'To: ' # Header class is smart enough to try US-ASCII, then the charset we # provide, then fall back to UTF-8. header_charset = 'ISO-8859-1' # We must choose the body charset manually for body_charset in 'US-ASCII', 'ISO-8859-1', 'UTF-8': try: body.encode(body_charset) except UnicodeError: pass else: break # Split real name (which is optional) and email address parts sender_name, sender_addr = parseaddr(sender) recipient_name, recipient_addr = parseaddr(recipient) # We must always pass Unicode strings to Header, otherwise it will # use RFC 2047 encoding even on plain ASCII strings. sender_name = str(Header(unicode(sender_name), header_charset)) recipient_name = str(Header(unicode(recipient_name), header_charset)) # Make sure email addresses do not contain non-ASCII characters sender_addr = sender_addr.encode('ascii') recipient_addr = recipient_addr.encode('ascii') # Create the message ('plain' stands for Content-Type: text/plain) msg = MIMEText(body.encode(body_charset), 'plain', body_charset) msg['From'] = formataddr((sender_name, sender_addr)) msg['To'] = formataddr((recipient_name, recipient_addr)) msg['Subject'] = Header(unicode(subject), header_charset) # Send the message via SMTP to localhost:25 smtp = SMTP(SMTPserver) smtp.sendmail(sender, recipient, msg.as_string()) smtp.quit() if verbose: print "This mail has been sent:\n" print sender print recipient print 'Subject: %s\n' %subject print body if __name__ == '__main__': sender = u'From: áÁčČďĎěĚéÉíÍňŇóÓřŘšŠťŤúÚůŮýÝžŽ <honza@ar.re.sa>' recipient = u'To: áÁčČďĎěĚéÉíÍňŇóÓřŘšŠťŤúÚůŮýÝžŽ <honza@ad.re.sa>' subject = u'Testovací mail áÁčČďĎěĚéÉíÍňŇóÓřŘšŠťŤúÚůŮýÝžŽ' body = u'áÁčČďĎěĚéÉíÍňŇóÓřŘšŠťŤúÚůŮýÝžŽbleble\n' send_email(sender, recipient, subject, body, verbose = True)
less /var/spool/mail/uzivatel
a to take neni med. Prikaz mail
ti ty zpravy alespon vylistuje apod.
Příkaz mail by měl skončit na propadlišti dějin. Tohoto třináct let starého dinosaura už na čtení mailů snad nikdo nepoužívá. A co se týče odesílání, to lze v pythonu nebo v perlu nahradit dvěma či třemi řádky kódu. Příkaz mail je dost častou příčinou toho, že roboti a skripty rozesílají maily se špatnou češtinou.Mail je jeste starsi (existovalo uucp) Existuji UNIXy, kde neni ani perl, ani python, ale mail(x) vzdy.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.