While the gaining of an indulgence requires one to be in a state of grace, even if one is in a state of mortal sin, ones prayers will be heard by God. That one is offering prayers for the faithful departed is a sign of one’s acceptance of God’s Justice, and desire to repair the breech between God and themselves. It does however bring up a couple of other things.
Mortal Sin: To commit a mortal sin, a person has to know that what they are doing is gravely offensive to God, and will to do it anyway. As an example; prior to the relaxation of the laws of fast and abstinance by Pope Paul VI, it was a mortal sin for healthy Catholics between the ages of (around) 7 and 65 to eat fleshmeat on Fridays. If you were sick and you needed to have meat or meat broth, if you would otherwise starve, or put health into grave danger, or if you forgot it was Friday, you would not have willed or desired to offend God. So even if you commited an act that was mortally sinful, you would have not met the requirements for the sin to be a mortal sin. You really have to work at it to commit a mortal sin.
Some deny that the Church has the authority to make and unmake laws like the laws of fast and abstinance, the Bible says otherwise. We are told in the Bible that we are to be obedient to our religious superiors. St. Paul calls himself the spiritual father of those subject to him. Ananaias and Saphorah were struck dead, when they lied to the Apostles, it was the same as telling a lie to the Holy Spirit.
Forgiveness of Sin: God forgives our sins, the manner he gave us is clear in the Bible, Jesus laid hands on the Apostles, and breathed on them, both Jewish rites for transmitting authority, telling them that whomever they forgave sins was forgiven, and whomever they retained (did not forgive) their sins were retained. As Catholics we believe that confessing to a priest, or bishop who are succssors of the Apostles, and have been given the authority to forgive sins in the name of Jesus, we also have to be sorry for our sins, and have the intention to reform our lives. We also believe that if there is no priest to hear our confession, we can make an act of perfect contrition, or tell God that we are sorry for our sins because they offend Him, and ask for forgiveness, we will be forgiven. Once a priest is availible, we should then confess our sins, so we can have the assurance that Jesus gave us when he gave the Apostles the authority to forgive sins in His name.
There is a priciple in Catholic theology, “The salvation of souls is the highest law” So we know that if there is no priest availible, and we are forgiven if we are contrite. If there is no priest to be had, we can baptize. If there is no priest we can still keep Sunday holy, and we can marry within Catholic law, with two Catholic witnesses, and it is a valid marriage. God and the Church hold us to what we have access to, and will not hold us to a standard that we cannot meet. So if there is no priest on Sunday, we still have the obligation to keep the day holy, but do not sin by missing Mass, since there is no Mass to attend.