This package includes functionality to work with any SFTP, IMAP and SMTP server
Project description
Package name is SFTP-SMTP-IMAP.
This package will simplify to work with SFTP, IMAP and SMTP server with the commonly used functionalities.
This package includes 3 classes (sftp, smtp and imap) to work with.
Dependency
pip install mail-parser==3.15.0
pip install pysftp==0.2.9
Class sftp:-
This class includes all the functions required to work with SFTP server.
setup_credentials(self, sftp_host, sftp_port, sftp_username, sftp_password, sftp_remote_locatio)
As a first step, user need to pass SFTP credentials for setting details in variables.
list_files_directories(self, remote_location, extension, prefix, postfix, within)
This will give list of files and directories based on criteria passed in
extension, prefix, postfix and within parameters.
create_remote_folder(self, remote_location, foldername)
This function can be used to create a folder on SFTP server.
delete_remote_folder(self, remote_location, foldername)
This function can be used to delete a folder on SFTP server.
rename_remote_folder(self, remote_location, old_foldername, new_foldername)
This function can be used to rename a folder on SFTP server.
upload_local_files(self, local_folder, remote_folder, list_of_filenames)
This function can be used to upload single or list of files on SFTP server.
download_remote_files(self, remote_folder, local_folder, list_of_filenames)
This function can be used to download single or list of files from SFTP server to local server/machine.
rename_remote_file(self, remote_location, old_filename, new_filename)
This function can be used to rename a file on SFTP server.
delete_remote_files(self, remote_location, list_of_filenames)
This function can be used to delete a single or list of files on SFTP server.
Class smtp:-
This class includes all the functions required to work with SMTP server.
setup_credentials(self, smtp_host, smtp_port, smtp_username, smtp_password)
As a first step, user need to pass SMTP credentials for setting details in variables.
sendmail_without_attachment(self, TO, CC, BCC, SUBJECT, BODY, FROM_EMAIL)
Use this function when you want to send email without any attachment.
sendmail_with_attachment(self, TO, CC, BCC, SUBJECT, BODY, ATTACHMENTS, FROM_EMAIL)
Use this function when you want to send email with single or multiple attachments.
Class imap:-
This class includes all the functions required to work with IMAP server.
setup_credentials(self, imap_host, imap_port, imap_username, imap_password)
As a first step, user need to pass IMAP credentials for setting details in variables.
email_verification(EmailSubject, FromEmail, Messageid, filter_for, prefix, postfix, within)
Use this function when you want to know the what mail to process from given mail folder.
download_attachments_only(self, mail_foldername, attachment_folder_location, filter_for="", prefix="", postfix="", within="")
Use this function when you want to download email attachments only.
purge_email(self, mail_foldername, list_of_messageid)
Use this function when you want to delete an email from mail folder.
Example of mail_foldername can be Inbox, Processed, Sent etc.
move_emails(self, source_mail_foldername, destination_mail_foldername, list_of_messageid)
Use this function when you want to delete an email from mail folder.
Example of source_mail_foldername/destination_mail_foldername can be Inbox, Processed, Sent etc.
save_email_data_in_xml(self, mail_foldername, xml_folder_location, filter_for="", prefix="", postfix="", within="")
Use this function when you want to download email details in a XML file.
save_email_data_in_xml_with_attachment_in_folder(self, mail_foldername, xml_folder_location, attachment_folder_location,filter_for="", prefix="", postfix="", within="")
Use this function when you want to download email details in a XML file along with attachments.
How to use this project:
For SFTP
-
from sftp.sftp import sftp
-
sftp.setup_credentials(sftp, "", , "", "") # Mandatory to use
-
sftp.list_files_directories(sftp, "")
-
sftp.create_remote_folder(sftp, "", "")
-
sftp.delete_remote_files(sftp, "", [""])
-
sftp.rename_remote_folder(sftp, "", "", "")
-
sftp.download_remote_files(sftp, "", "", [""])
-
sftp.upload_local_files(sftp, "", "", [""]) # This function return result in form of "SUCCESS" or "FAILURE"
for a single or list of files. This will be a collective result of processing. -
sftp.rename_remote_file(sftp, "", "", "")
-
sftp.delete_remote_files(sftp, "", [""])
For SMTP
-
from smtp.smtp import smtp
-
smtp.setup_credentials(smtp,"", , "", "") #Mandatory to use
-
smtp.sendmail_without_attachment(smtp, "", "", "", "", "", "")
-
smtp.sendmail_with_attachment(smtp, "", "", "", "", "", [""], "")
For IMAP
-
from imap.imap import imap
-
imap.setup_credentials(imap, "","" , "", "") #Mandatory to use
-
imap.download_attachments_only(imap, "", "", filter_for="", prefix="", postfix="", within="")
-
imap.purge_email(imap, "", "")
-
imap.move_emails(imap, "", "", "")
-
imap.save_email_data_in_xml(imap, "", "", filter_for="", prefix="", postfix="", within="")
-
imap.save_email_data_in_xml_with_attachment_in_folder(imap, "", "", "", filter_for="", prefix="", postfix="", within="")
This package is developed by Sunesh Pandita. GitHub repo:- Link
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sftp_smtp_imap-1.0.4.tar.gz.
File metadata
- Download URL: sftp_smtp_imap-1.0.4.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afa8d7c78b56bab471a56053ccdd1abace666d8605d05217f87761aa3e472823
|
|
| MD5 |
849f58d3ad619233c2b47edc41372783
|
|
| BLAKE2b-256 |
859e06f2008f0a835264787346864be2130451d882efb97576385a45e0ed0fd3
|
File details
Details for the file sftp_smtp_imap-1.0.4-py3-none-any.whl.
File metadata
- Download URL: sftp_smtp_imap-1.0.4-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdba32d25ac025aec3c731d9eb72206c34e4e2232d9f8c6aeab49f171c94f218
|
|
| MD5 |
6e3c5c48ac8c4ebd81ec4e0cde210ff2
|
|
| BLAKE2b-256 |
119f7774e6bfb8d54bad6f0015b5101f12477dd17a6533c0af231c6b12bbf3a1
|