Made to Order Software Corporation Logo

The set_fax_id() function PHP e-Fax must be given unique IDs, each time.

Fax button on an old type of fax machine

The PHP eFax system uses a class that ease the communication between your software and eFax. The developer system is not too complicated, but there are tricks to it and the class hides most of them.

Today a customer contacted us as they just purchased a copy of our PHP library and had problems sending faxes. The fact is that they used the set_fax_id() function with a hard coded string. Imagine doing something like:

$efax->set_fax_id("Test Fax");

This looks pretty good, only after the second time the sending of the fax will fail because eFax considers that it was already sent.

What you need to do is: make sure that each time you send a fax, you use a new identifier. For example, if you are working with customer orders, you could use your unique order number as the fax identifier:

$efax->set_fax_id("Order #" . $order_no);

Now you have a fax identifier which is unique. However, if you allow for the sending on the same order more than once, that technique won't work. Instead you could use a counter. Create a BIGINT in your database. Make it a SERIALIZE type (auto-increment). Then get a new value each time you send a fax.

$fax_count = $database->fetch(); // hypothetical
$efax->set_fax_id("Fax #" . $fax_count);

Use whatever technique makes sense in your software, or do not set the fax identifier and let eFax do it for you (it is returned with the answer.)

This identifier can later be used to access the fax data saved by eFax such as how many attempts were made or whether the fax was successfully sent or not.

See the function documentation. (Since version 1.9, the documentation clearly says that it has to be unique.)

If you have any additional questions about PHP e-Fax, don't hesitate to contact us.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.