Python Fax - Send Multiple Files to Multiple Recipients

Download the Python fax code samples and library.

This Python fax sample uses the SendfaxEx_2 method to send a fax from Python to one or more recipients with one or more attached files. SendfaxEx_2 has more flexible sending capabilities than SendFax (for more details, see Side-by-side Comparison of Web Service Methods).

In the Python fax snippet below, a few files are read and submitted to the fax Web service, and the return value indicates whether the submission succeeded.

The return value of a successful submission is the transaction ID (positive number) of the fax in the system. Other return values indicate a failure (for more details, see Web Service Return Codes).

"""
A simple script to send an ASCII fax the InterFAX  
SendFaxEx_2 SOAP API call.
"""
from interfax import client
 
print 'Testing SendFaxEx_2...'
c = client.InterFaxClient('USERNAME','PASSWORD') # Enter your Interfax username/password here
result = c.sendFaxEx2( ['+12125554874'], ['mike smith'], ['etc/sample.pdf','etc/sample.html']) # Enter the destination fax number here.
print '   Fax was sent with result code: %d' % result
 
"""
In case of successful submission, result will contain a positive 
Transaction ID.
 
A negative value means an error occurred.
See the InterFax Status Codes: http://www.interfax.net/en/dev/webservice/reference/web-service-return-codes
"""