Code Snippet: Run Lead Auto-Response Rules for all Leads

trigger RunLeadAutoResponseRules on Lead (after insert) {

    List<LeadnewlyInsertedLeads = [SELECT Id From Lead WHERE Id IN]; 
    Database.DMLOptions dmo = new Database.DMLOptions();
    dmo.emailHeader.triggerUserEmail = true;
    for (Lead l : newlyInsertedLeads ) { 
        Database.update(l, dmo); 

It’s a good idea to limit this type of trigger to only run for certain types of leads, so a suggestion is to add a check for specific Lead Source, such as LeadSource == 'Web'Read more