Author's home

Table Of Contents

This Page

pyzsendmail manual page


pyzsendmail [options]


pyzsendmail compose and send mails.

Compose an email including text and/or HTML content, add attachments of any kind, or embed images in the HTML content. Depending the need, pyzsendmail adapts the MIME structure of the email.

pyzsendmail handle SSL, TLS and authentication.

pyzsendmail can send to one or multiple recipients, but also support CC and BCC recipients.


-h, --help

show this help message and exit

-H name_or_ip, --smtp-host=name_or_ip

SMTP host relay

-p port, --smtp-port=port

SMTP port (default=25)

-L login, --smtp-login=login

SMTP login (if authentication is required)

-P password, --smtp-password=password

SMTP password (if authentication is required)

-m mode, --smtp-mode=mode

smtp mode in ‘normal’, ‘ssl’, ‘tls’. (default=’normal’)

-A charset, --arg-charset=charset

command line arguments charset (default=<depend of the host locals>)

-C charset, --mail-charset=charset

mail default charset (default=<depend of the host local>)

-f sender, --from=sender

sender address

-t recipient, --to=recipient

add one recipient address

-c recipient, --cc=recipient

add one CC address

-b recipient, --bcc=recipient

add one BCC address

-s subject, --subject=subject

message subject

-T text, --text=text
text content in the form
[text_charset]:”litteral content”
-M html, --html=html
html content in the form
[text_charset]:”literal content”
-a file, --attach=file
add an attachment in the form:
for example
-e file, --embed=file
add embedded data in the form:
for example
-E, --eicar

include eicar virus in attachments, for testing Anti-virus


login and password must be utf-8 encoded if they contains non us-ascii
address can be of the form:

“Foo Bar <>”



Name can contain non us-ascii characters. They are supposed to use the command line charset encoding.

text and HTML content can be in the literal form:
  • :”The text content”
  • utf8:”The text content”

In both samples, the content is encoded using the encoding of the command line argument. In first sample, notice the : at beginning, the content will be encoded using the mail default charset, in the second sample, the text will be re-encoded into utf8.

or using content of a file:

  • :@”C:\file.txt”
  • windows-1252:@”C:\file.txt”

In first sample, notice the : at beginning, the file is supposed to be encoded using mail default charset and will be encoded this way in the email. In second sample, the file is supposed to be encoded using windows-1252 charset and will be encoded this way in the email.

attachment and embedded files
In attachment and embedded content, the text_charset is used only if the maintype is ‘text’. The file is supposed to be encoded using text_charset and will be encoded using this charset in the email.


pyzsendmail -H localhost -p 25 -f "Me <me\>" -t "foo\" -t "Bar <bar\" -s "The subject" -T :"Hello" -a image/jpg:holiday.png:C:\\Holiday.png

See also



Alain Spineux <>