OPINION OF THE COURT
BECKER, Circuit Judge.Appellant Walter Guyer, who was incarcerated at the State Correctional Institution (SCI) at Cresson, Pennsylvania, refused to sign a form power of attorney consenting to the receipt of his mail by prison officials because he claimed that it interfered with his right of access to the *1426courts. As a result, the prison returned Guyer’s mail, including correspondence from the federal courts, to the post office marked “refused.” After Guyer filed a petition for a writ of habeas corpus in the district court for the Western District of Pennsylvania, the court required him to execute a limited power of attorney form in order to receive mail related to his case. Because Guyer refused to sign, the district court dismissed his habeas petition. This appeal presents the question whether the district court properly dismissed Guyer’s habeas petition because of his persistent refusal to obey a pretrial order that he claimed infringed his right of access to the courts. For the reasons that follow, we hold that the habeas petition was properly dismissed, and we will affirm the district court’s order of dismissal.
I. PROCEDURAL HISTORY
In addition to seeking release from prison, Guyer’s habeas petition requested “preliminary relief” in order to enable him to have access to the courts.1 Guyer named Jeffrey A. Beard, the warden of SCI at Cresson, as the defendant. As part of his requested “preliminary relief,” Guyer sought an order compelling the prison officials at SCI Cresson to deliver his mail to him.2 He alleged that Pennsylvania Department of Corrections officials had stopped his incoming mail in March 1988. Guyer also sought: (1) the return of his legal materials, which had been left at SCI Dallas when he was transferred to SCI Cresson; (2) legal postage at state expense; and (3) direct access to an adequate law library or professional legal services. The district court ordered the warden to respond to Guyer’s allegations concerning his mail. Additionally, the court directed Guy-er to file both a civil rights complaint and a proper habeas petition on standard forms provided by the district court clerk’s office. The district court apparently construed Guyer’s request for preliminary relief as presenting civil rights claims.3
In his answer, the warden stated that he was not delivering Guyer’s mail to him because Guyer had failed to execute a power of attorney form, which provides in pertinent part:
I do make, constitute, and appoint the Superintendent/Director of this institution, or his/her authorized representative ... my true and lawful attorney for me and in my name to sign my name as endorsement on all checks, money orders, or bank drafts for deposit to my credit in the Inmate’s Escrow Account and to receive and document receipt of mail on my behalf.
The warden explained that United States Postal Service regulations require inmates to sign a power of attorney form in order to authorize the prison to receive the inmates’ mail.4 The district court thereupon ordered Guyer to sign a power of attorney form limited to authorizing the prison’s receipt of the court’s orders and notices *1427pending the adjudication of the validity of the regulations concerning the power of attorney form. The order further provided that the failure to complete a limited power of attorney form would result in dismissal of the complaint. Finally, the district court directed Guyer to comply with the prior order, which required him to file an amended habeas petition and a civil rights complaint by August 21, 1989.
Guyer filed a civil rights complaint and amended habeas petition pursuant to the district court’s order.5 In his amended ha-beas petition, Guyer objected to signing the limited power of attorney form and noted that the court had not given him a deadline for signing such a form. By order entered September 1, 1989, the district court dismissed Guyer’s civil rights complaint, which had pleaded Guyer’s contention that the power of attorney requirement was unconstitutional. In the September 1 order, the district court directed Guyer to sign a limited power of attorney form by September 8, 1989.6 Guyer, however, declined to sign the form.7 Finding that Guyer’s refusal to execute the form made communication among the parties and the court impracticable, and that it was unreasonable for a prison to make accommodations to deliver mail to an inmate in person, the district court dismissed Guyer’s habeas petition by order entered September 15, 1989. This appeal followed.
When an appeal is taken from an order dismissing a habeas petition where the detention complained of arises out of process issued by a state court, we must ordinarily first issue a certificate of probable cause before the appeal can proceed. See Fed.R.App.P. 22(b). However, we may consider the merits of this appeal together with the request for a certificate of probable cause because we provided Guyer with notice of our intention to do so by letter dated May 29, 1990. See Garrison v. Patterson, 391 U.S. 464, 466, 88 S.Ct. 1687, 1688, 20 L.Ed.2d 744 (1968) (per curiam). Guyer received the May 29 letter on May 31, 1990.8 On June 13, 1990, we received an affidavit from Guyer in support of his appeal and request for a certificate of probable cause, in which he contended that the failure of Department of Corrections officials to deliver his incoming mail violated his constitutional right of access to the courts.
We now render our decision upon both the merits of the appeal and the request for a certificate of probable cause. Although it does not affect our analysis, we note preliminarily that this is a somewhat anomalous habeas appeal inasmuch as the merits issues seem much more like civil rights issues than habeas issues. However, since the habeas petition was dismissed because Guyer refused to sign a limited power of attorney form, which he asserted deprived him of access to the courts (typical fodder for a civil rights case), that is the end result. In view of this situation, our decision does not address the merits of Guyer’s habeas claims or determine whether those claims have been exhausted. Instead, our decision addresses *1428the reasonableness of the district court’s pretrial order and later dismissal of the habeas petition for Guyer’s failure to obey the pretrial order.
II. THE PRETRIAL ORDER
The district court ordered Guyer to sign a power of attorney form limited to authorizing the warden’s receipt of the court’s orders and notices pending the adjudication of the power of attorney form itself. The district court noted that failure to comply with its order would result in dismissal of the habeas petition. In dismissing Guyer’s habeas action for failure to obey this order, the district court specifically found that it would be unreasonable to require the warden to deliver Guyer’s mail personally. Because this decision by the district court is a legal conclusion involving the interpretation and application of legal precepts, our review is plenary. McCandless v. Beyer, 835 F.2d 58, 60 (3d Cir.1987).
The order directing Guyer to sign a limited power of attorney form was a reasonable order entered by the district court to further the efficient management of its caseload. However, Guyer objected to the district court’s order, claiming that it denied his right of access to the courts while giving the warden a right he could not constitutionally exercise. We disagree. By requiring Guyer to execute a limited power of attorney form, the district court furthered communication between the parties and the court while also furthering the warden’s legitimate interest in prison security. See Turner v. Safley, 482 U.S. 78, 89, 107 S.Ct. 2254, 2261-62, 96 L.Ed.2d 64 (1987) (prison regulations are constitutional if reasonably related to legitimate penological interest). The limited power of attorney form that Guyer refused to execute would have authorized prison officials to receive and document the receipt of his mail related to his case. See supra p. 1426. This would directly further communication between the parties and the court. The limited power of attorney form also would have enabled the warden to comply with United States Postal Service, Domestic Mail Manual § 115.97, which requires prison officials to obtain the inmates’ consent to the prison’s receipt of their mail so that prison officials can open, inspect, and censor incoming mail.9 Without such consent, the prison would have to deliver the mail unopened, or else return it to the post office marked “Refused.”
By objecting to the warden’s decision to have his mail returned to the post office, rather than delivered unopened, Guyer was claiming, in effect, a constitutional right to have his mail delivered unopened. While it is clear that Guyer’s right of access to the courts would be burdened if he failed to receive mail related to his pending lawsuit and as a result did not learn of deadlines and rules relevant thereto, it is also clear that requiring the warden to deliver Guy-er’s mail unopened could adversely affect prison security because contraband could be delivered to Guyer undetected. Preventing the introduction of contraband into the prison is unquestionably a legitimate penological interest. See Wolff v. McDonnell, 418 U.S. 539, 577, 94 S.Ct. 2963, 2985, 41 L.Ed.2d 935 (1974) (Constitution allows prisons to open attorney mail addressed to inmate in presence of inmate in order to inspect for contraband). Under Pennsylvania regulations, the warden can have incoming inmate mail from the courts and attorneys opened in the presence of the inmate-addressees to inspect for contraband. 37 Pa.Code §§ 93.2(b)(2),-(d),-(e)(2), *142995.234(a)(6),-(7).10 However, the United States postal regulation limits the warden’s authority to open an inmate’s mail to those inmates who consent to the warden’s receipt and opening of their mail.
As a result, the district court’s order enabled it to communicate with Guyer without undermining the warden’s interest in prison security. Such an accommodation of both Guyer’s need to receive mail related to his case and the prison’s legitimate interest in inspecting incoming mail for contraband does not deny Guyer his right of access to the courts. Cf. Turner, supra. Accordingly, we hold that the district court’s order requiring Guyer to execute a limited power of attorney form did not infringe upon Guyer’s right of access to the courts and that it was a reasonable pretrial order.
III. DISMISSAL AS SANCTION
By dismissing Guyer’s habeas petition because of his failure to sign the limited power of attorney form, the district court exercised its inherent power under Fed.R.Civ.P. 41(b) to dismiss a complaint for a plaintiff’s failure to comply with a district court’s order. We review the district court’s dismissal under an abuse of discretion standard. See Carter v. Albert Einstein Medical Center, 804 F.2d 805, 807 (3d Cir.1986). Under our jurisprudence, the sanction of dismissal is reserved for those cases where the plaintiff has caused delay or engaged in contumacious conduct. Even then, it is also necessary for the district court to consider whether the ends of justice would be better served by a lesser sanction. See id. at 807; Pickel v. United States, 746 F.2d 176, 182 (3d Cir.1984); Donnelly v. .Johns-Mansville Sales Corp., 677 F.2d 339, 342 (3d Cir.1982).
In this case, the district court directed Guyer to sign a limited power of attorney form pending the final adjudication of the validity of the regulation requiring the execution of .a power of attorney form. Guyer refused to sign that form. Because Guyer’s conduct in disobeying the court’s orders was contumacious, we are satisfied that the district court did not abuse its discretion in dismissing the habeas petition.11
Under Carter, a district court must use dismissal as a sanction of last resort. See 804 F.2d at 807. The court should consider *1430whether a lesser sanction would better serve the interests of justice. While the district court did not do so in these terms, it gave Guyer several chances to sign a limited power of attorney form, yet Guyer continued to refuse to sign the form. From Guyer’s conduct it is apparent that he had no intention of signing a limited power of attorney form in order to communicate with the court pending the adjudication of his claims. Guyer’s position made adjudication of the case impossible. Therefore, any lesser sanction' would not have furthered the interests of justice. We therefore hold that dismissal of Guyer’s habeas petition was a proper sanction for his refusal to obey the district court’s order.
For the foregoing reasons, a certificate of probable cause to appeal will be granted, and the district court’s order dismissing Guyer’s habeas corpus petition will be affirmed.
. Guyer’s initial habeas petition did not list any grounds for release because he claimed that he needed his legal papers, which were left behind when he was transferred from SCI Dallas to SCI Cresson, in order to present them. In an amended petition, Guyer raised the following grounds: his criminal prosecution was in retaliation for legal actions he had brought against Chester County; he was prosecuted twice for the same criminal conduct or episode; his rights under the Interstate Agreement on De-tainers were violated; he was improperly sentenced under Pennsylvania’s sentencing guidelines; his sentence was not credited for time served in Delaware; and the Double Jeopardy Clause was violated by an increase in one of his sentences from 1-5 years to l'AS years.
. Guyer has since been transferred to SCI Hun-tingdon.
. Because the civil rights claims and habeas claims present separate and distinct issues and are not based upon the same underlying facts, Guyer’s habeas petition did not trigger the concerns and procedures applicable to mixed habe-as petitions discussed in Harper v. Jeffries, 808 F.2d 281, 285 (3d Cir.1986).
. The use of power of attorney forms by SCI Graterford has been challenged unsuccessfully in other lawsuits. See Guyer v. Zimmerman, No. 86-6023, slip op., 1986 WL 13638 (E.D.Pa. Nov. 26, 1986); Toth v. Zimmerman, No. 85-3803, slip op., 1986 WL 3856 (E.D.Pa. March 31, 1986). Guyer was the plaintiff in one of these lawsuits, but we make no finding as to whether that case is res judicata as that issue has not been raised by the warden.
. The district court had both the civil rights complaint and the amended habeas petition docketed under the same number.
. Guyer filed a notice of appeal from the-September X order on September 13, 1989. That appeal was dismissed on December 27, 1989 for failure to prosecute.
. The limited power of attorney form that Guy-er refused to sign was prepared by the warden’s administrative assistant. It added the following language to the standard power of attorney form: "Limited Powder [sic] Attorney this will authorize the State Correctional Institution at Cresson to receive incoming mail from the US District Court, Western District Civil Action # 89-112 J.”
.The May 29 letter informed the parties that the court would consider summarily affirming the district court’s decision pursuant to this court's Internal Operating Procedures, Chapter 17 [Summary Action]. Because Guyer had refused to execute a limited power of attorney form, and our prior correspondence dated September 29, October 6, and November 6, 1989 had been returned, we requested the Superintendent at SCI Huntingdon to have our May 29, 1990 notice hand delivered to Guyer with all our previous correspondence attached. We provided a receipt form which Guyer signed when he received the notice.
. The postal regulation provides: "Authorized personnel of prisons, jails, or other correctional institutions, in accordance with lawful rules and regulations, may open, examine, and censor mail addressed to an inmate of the institution, if the inmate-addressee consents to receive his mail at the institution through the institutional authorities. If the inmate does not consent, the personnel may either deliver the inmate's mail to the inmate unopened, or return it to the post office unopened marked ‘Refused.’ An inmate may designate in writing an agent outside the institution to receive his mail, either through an authorized address of the agent, if the mail is so addressed, or at the delivery post office serving the institution, if the mail is addressed to the inmate at the institution.”
. 37 Pa.Code § 93.2 provides in relevant part: (b) Restrictions. The following restrictions apply:
(2) Correspondence containing threatening or obscene material, as well as correspondence containing criminal solicitation or furthering a criminal plan or institution misconduct is prohibited.
(d) Privileged correspondence.
(1) Correspondence, which is- marked as ... from the following persons should be considered privileged:
(1) Elected or appointed Federal, State or local officials.
(ii) Attorneys.
(3) Privileged correspondence received by the institution will be delivered to the housing unit officer and opened by the officer in the presence of the addressee. It will be checked for contraband.
(e) Scrutiny of correspondence.
(2) The institution may read privileged mail, only upon the written order of the Superintendent with the written approval of the Commissioner of Corrections when there is reason to believe that there is a threat to security, or criminal activity, or this section is being abused.
.37 Pa.Code § 95.234(a) provides in relevant part:
(6) Incoming and outgoing letters, with the exception of those outgoing letters addressed to public officials and therefore sealed, may be opened and examined for contraband. They shall not be read. .
(7) Incoming mail from attorneys, courts, Bureau of Correction personnel, and other public officials shall be opened and examined for contraband in the presence of the addressee.
. Judge Seitz believes the district court had no right to direct the plaintiff to sign the limited power of attorney, and that all the court could do was to grant plaintiff access to his mail upon the condition that he execute the power of attorney form, subject to the possibility that his action would be dismissed for failure to comply with other court orders or requirements. With all respect, we see’ no functional difference between Judge Seitz’s approach and our own.