It is NOT safe to look at the sun through DSLR or Mirrorless camera lens, even if you are wearing eclipse glasses. Optical lenses concentrate light, and the sun's rays will burn through the solar filter. It will also damage your camera lens. If you want to take more professional looking photos with these type of cameras you can view Nikon's guide to safely photographing an eclipse.
When you take a picture with your phone though, your eye is not lined up with the lens so it is much less likely to cause eye damage. According to Apple, the eclipse will not damage your phone's camera, but newer more powerful smartphone cameras can take in more light than older models, and sources are unclear on wether it is enough to damage your camera. Because of this, it's best to cover your lens with an extra pair of solar glasses; this will also give you better pictures.
The only time it is safe to look at or photograph an eclipse without solar filters is DURING totality, where the sun is completely covered by the moon. But, even the small slivers of light that are visible before and after totality are enough to damage your eyes and camera.