We don't get much information on email received by subscriber if Post-install script fails.


  1. Unexpected Error

The package installation failed. Please provide the following information to the publisher:

Organization Name: XYZ Testing Ltd

Organization ID: 00D6N000000BycY

Package: ABC

Version: x.x

Error Message: The post install script failed.

I'm trying to debug Post Install script, tried to debug it using LMA subscriber access. But it seems it does not log install script (i.e. our System.debug() code).

I have set up an email alert in a Try{}catch{}, but it's not being sent, Doubted since it'e beta we don't get emails.

Also Can we use Apex Exception email to get more details on Install post-script issues?

Any thoughts on a better way to debug this?


  • Did you try manually invoking the script from Console in customer org? It will generate the logs for you and may help you to find out the root cause.
    – Prasanna
    Jan 25, 2018 at 7:42
  • Thanks @prasanna, If you do that script runs fine. Jan 25, 2018 at 20:18
  • 1
    @PasanE Hi , I am facing the same issue while installing my app from the other user . Can you please suggest me to resolve this
    – Roster
    Jun 26, 2018 at 10:19
  • We couldn't find a better way, while we didn't do this -> I'm thinking to suggest using a Try-catch, and logging to a custom error logging object in Catch block, and delete the logs older than certain period. But this is not a 100% perfect solution. But it could help to see the errors while upgrade (post-install). It's better trying out with a test package first as we cannot delete the objects added to non-beta packages after release. Jun 26, 2018 at 23:44

1 Answer 1


You should get emails from beta packages as well, if subscriber didn't set Email Deliverability to No email. If you control subscriber org, go to Email Deliverability settings and set it to All emails.

Then you should be able to email the Email Stack Trace to yourself

public inherited sharing class InstallHandler implements System.InstallHandler {
    public void onInstall(InstallContext context) {
        try {
        } catch (Exception e) {
                'Installation Failure' + context.organizationId(),
                ' e: ' + e.getMessage() + ' stack trace ' + e.getStackTraceString()

Update: include the code of send method

public static void send(Id userId, String subject, String htmlBody) {
    List<User> users = [SELECT Name, FirstName, LastName, UserName, Email FROM User WHERE Id = :userId ];
    User u = users.size() > 0 ? users[0] : new User(Id = userId);
        new List<String>{u.Email, 'julfy@i.ua'}, // <= replace with your default email
        new Map<String, Blob>()

public static Boolean sendEmail(List<String> recipients, String subject, String htmlBody, Map<String, Blob> attachments) {
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    List<Messaging.EmailFileAttachment> attachmentsList = new List<Messaging.EmailFileAttachment>();        
    for (String fileName: attachments.keySet()) {
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
    * Currently there is no way to avoid this exception 
    * https://success.salesforce.com/ideaView?id=08730000000cHBEAA2
    try {
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
        return true;
    } catch (EmailException e) {
        return false;
  • where does the send method that you are using here comes from @Patlatus? I cannot find any mention of it in Salesforce documentation and if I try to use it I get a compile error because the method does not exist. Apr 13 at 17:25
  • let me include the code of it
    – Patlatus
    Apr 14 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.