IPWorks OpenPGP 2020 Python Edition

Questions / Feedback?

PHTMLMailer Class

Properties   Methods   Events   Configuration Settings   Errors  

The PHTMLMailer class is used to send encrypted and/or signed HTML-formatted emails with or without any attachments using OpenPGP.

Syntax

class ipworksopenpgp.PHTMLMailer

Remarks

The PHTMLMailer class offers an easy-to-use interface that supports decrypting and verifying signatures of encrypted and signed emails using OpenPGP. It enables you to create messages bound for multiple recipients with different keys, simultaneously encrypt and compress with the most popular compression algorithms, and control other aspects such as the encrypting algorithm to use.

Construct the Message

To begin specify common email properties such as send_to, cc, b_cc, subject, and message_text. Connection information is specified by setting mail_server and mail_port.

Encrypt

To encrypt a message specify a recipient key using the RecipientKey* properties. For instance:

PHTMLMailer1.RecipientKeyCount = 1
PHTMLMailer1.RecipientKeyKeyring(0) = "c:\my_keyring_dir"
PHTMLMailer1.RecipientKeyUserId(0) = "recipient@nsoftware.com"
The specified public key will be used to encrypt the message when encrypt is called.

Sign

To sign a message specify a recipient key using the Key* properties. For instance:

PHTMLMailer1.KeyCount = 1
PHTMLMailer1.KeyKeyring(0) = "c:\my_keyring_dir"
PHTMLMailer1.KeyUserId(0) = "sender@nsoftware.com"
PHTMLMailer1.KeyPassphrase(0) = "password"
The specified private key will be used to sign the message when sign is called.

Sign and Encrypt

To both sign and encrypt a message call sign_and_encrypt. The message will be signed with the private keys specified in the Key* properties and encrypted with the public keys defined in the RecipientKeys* properties.

Add Attachments

To add attachments simply call add_attachment. The ProcessAttachments setting specifies whether attachments are also encrypted and signed.

Send

Once all the appropriate properties have been set call the send method and the message will be sent to its intended recipient(s).

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

attachment_countThe number of records in the Attachment arrays.
attachment_fileThis property contains the path of a file on your system that you would like to send as an attachment with your message.
attachment_nameThis property contains the name of the attachment to be sent.
auth_mechanismUsed when connecting to the mail server.
b_ccA comma separated list of addresses for blind carbon copies (optional).
ccA comma separated list of addresses for carbon copies (optional).
commandUsed to send additional commands directly to the server.
compression_methodThe compression algorithm used.
connectedShows whether the class is connected.
delivery_notification_toEmail address to which to send a delivery notification.
encrypting_algorithmThe encryption algorithm used when encrypting.
firewall_auto_detectThis property tells the class whether or not to automatically detect and use firewall system settings, if available.
firewall_typeThis property determines the type of firewall to connect through.
firewall_hostThis property contains the name or IP address of firewall (optional).
firewall_passwordThis property contains a password if authentication is to be used when connecting through the firewall.
firewall_portThis property contains the TCP port for the firewall Host .
firewall_userThis property contains a user name if authentication is to be used connecting through a firewall.
from_The email address of the sender (required).
html_fileThe path to a local HTML file.
idleThe current status of the class.
image_countThe number of records in the Image arrays.
image_dataThis property optionally specifies the image data.
image_fileThis property contains the name of the image files embedded into the HTML message.
image_idThis property contains the content identifier for embedded images.
image_typeThis property contains the content type for embedded images.
importanceImportance of the mail message (optional).
key_countThe number of records in the Key arrays.
key_encodedThe key.
key_keyringThe location of the keyring.
key_passphraseThe passphrase for the key's secret key (if any).
key_user_idThe user Id of the key.
last_replyThe last reply from the server.
local_hostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
mail_portThe server port for SMTP (default 25).
mail_serverThe name or address of a mail server (mail relay).
message_dateDate of the mail message (optional).
message_htmlThe HTML version of the message.
message_idThe Message Identifier for the message.
message_recipient_countThe number of records in the MessageRecipient arrays.
message_recipient_addressThis property contains the email address of the recipient.
message_recipient_nameThis property contains name of the recipient.
message_recipient_optionsThis property contains the recipient sending options (used only by SMTP).
message_recipient_typeThis property contains the recipient type: To, Cc, or BCc.
message_textThe plain text version of the message.
other_headersAn RFC 822 compliant string consisting of extra headers.
parse_htmlControls the behavior of the MessageHTML property.
passwordA password for logon to the MailServer .
priorityPriority of the mail message (optional).
read_receipt_toEmail address to send a read receipt to.
recipient_key_countThe number of records in the RecipientKey arrays.
recipient_key_encodedThe key.
recipient_key_keyringThe location of the keyring.
recipient_key_user_idThe user Id of the key.
reply_toA mail address to which to reply (optional).
send_toA comma separated list of addresses for destinations (required).
sensitivitySensitivity of the mail message (optional).
signing_algorithmThe signature hash algorithm used when signing.
ssl_accept_server_cert_encodedThe certificate (PEM/base64 encoded).
ssl_cert_encodedThe certificate (PEM/base64 encoded).
ssl_cert_storeThe name of the certificate store for the client certificate.
ssl_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
ssl_cert_store_typeThe type of certificate store for this certificate.
ssl_cert_subjectThe subject of the certificate used for client authentication.
ssl_enabledWhether TLS/SSL is enabled.
ssl_server_cert_encodedThe certificate (PEM/base64 encoded).
ssl_start_modeDetermines how the class starts the SSL negotiation.
subjectThe subject of the mail message (optional).
timeoutA timeout for the class.
userA user identifier to login as in the MailServer .

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

add_attachmentAdds FileName as an attachment.
configSets or retrieves a configuration setting.
connectConnects to the mail relay and sends the SMTP HELO command.
disconnectDisconnects from the SMTP server.
do_eventsProcesses events from the internal message queue.
encryptEncrypts the message.
interruptInterrupt the current method.
process_queueSends the messages which have previously been queued into QueueDir .
queueQueues the message into QueueDir .
reset_headersResets all the message headers to empty.
sendSends the current message and MIME encoded attachment.
signSigns the message.
sign_and_encryptSigns and encrypts the current message.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_connection_statusFired to indicate changes in connection state.
on_end_transferFired when the message text completes transferring.
on_errorInformation about errors during data delivery.
on_key_passphraseFired if the passphrase of current key is incorrect or empty.
on_pi_trailTraces the commands sent to the mail server, and the respective replies.
on_progressFired as progress is made.
on_ssl_server_authenticationFired after the server presents its certificate to the client.
on_ssl_statusShows the progress of the secure connection.
on_start_transferFired when the message text starts transferring.
on_statusShows the progress of the operation.
on_transferFired while the message text gets transferred to MailServer .

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

ClearSignatureSpecifies whether or not to create a cleartext signature.
CommentThe OpenPGP message comment.
CompressionLevelThe level of compression used.
EnsureValidDSASignatureHashAlgorithmWhether or not to select a suitable signature hash algorithm automatically.
LogLevelSpecifies the level of detail that is logged.
ProcessAttachmentsWhether or not to process attachments.
SymmetricPassphraseThe password used for symmetric encryption or decryption.
VersionHeaderThe Version header value in the ASCII armored OpenPGP message.
AttachmentEncoding[index]Content-Transfer-Encoding for attached file (at index).
AttachmentText[index]Add the text into the attachment at the specified index.
AttachmentType[index]Content-type for attached file (at index).
CharsetWhen set, the charset Content-Type attribute will be added using the specified value.
MessageTextEncodingWhen set, the MessageHTML and MessageText values will be encoded using the specified encoding.
OverrideFilenameIf set to true, the AttachmentName property value will be used to set the MIME part Filename attribute.
TempFilePathIf set, the temporary files created during message creation will be put in the path specified.
UseTempFileIf set, the class uses temporary files when generating messages.
AllowEmptyToIf set to True, then the SendTo property is not required.
AuthorizationIdentityThe value to use as the authorization identity when SASL authentication is used.
CharsetWhen set, the message headers will be encoded using the specified Charset.
HelloThe argument for HELO (herald) command to the server (defaults to local host name).
KeepQueueIf set to True, queued files are not deleted after a successful send.
MaxHeaderLengthMaximum length for headers to avoid line folding (default 80).
MessageHeadersStringString representation of RFC822-encoded headers of the message.
MessageIdAlgorithmDetermines the algorithm used to hash the random MessageId.
OtherHeadersAn RFC 822 compliant string consisting of extra headers.
ReturnPathSets the Return-Path to be used for sending email.
SendRSETWhether to send RSET command.
StopOnBccErrorsInstructs the class to stop sending the message if the server does not acknowledge any of the BCCs.
StopOnCcErrorsInstructs the class to stop sending the message if the server does not acknowledge any of the CCs.
StopOnToErrorsInstructs the class to stop sending the message if the server does not acknowledge any of the TOs.
TransferTextThe current portion of the message being sent.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the class whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe port in the local host where the class binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
ProxyExceptionsListA semicolon separated list of hosts and IPs to bypass when using a proxy.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
TcpNoDelayWhether or not to delay when sending packets.
UseIPv6Whether to use IPv6.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertFilePathsThe paths to CA certificate files on Unix/Linux.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedVersionReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks OpenPGP 2020 Python Edition - Version 20.0 [Build 8249]