Social structure is proposed to influence the transmission of both directly and environmentally transmitted infectious agents. However in natural populations, many other factors also influence transmission, including variation in individual susceptibility and aspects of the environment that promote or inhibit exposure to infection. We used a population genetic approach to investigate the effects of social structure, environment, and host traits on the transmission of Escherichia coli infecting two populations of wild elephants: one in Amboseli National Park and another in Samburu National Reserve, Kenya. If E. coli transmission is strongly influenced by elephant social structure, E. coli infecting elephants from the same social group should be genetically more similar than E. coli sampled from members of different social groups. However, we found no support for this prediction. Instead, E. coli was panmictic across social groups, and transmission patterns were largely dominated by habitat and host traits. For instance, habitat overlap between elephant social groups predicted E. coli genetic similarity, but only in the relatively drier habitat of Samburu, and not in Amboseli, where the habitat contains large, permanent swamps. In terms of host traits, adult males were infected with more diverse haplotypes, and males were slightly more likely to harbor strains with higher pathogenic potential, as compared to adult females. In addition, elephants from similar birth cohorts were infected with genetically more similar E. coli than elephants more disparate in age. This age-structured transmission may be driven by temporal shifts in genetic structure of E. coli in the environment and the effects of age on bacterial colonization. Together, our results support the idea that, in elephants, social structure often will not exhibit strong effects on the transmission of generalist, fecal-oral transmitted bacteria. We discuss our results in the context of social, environmental, and host-related factors that influence transmission patterns.