<th>$username has sent you a photo!</th>
<img src="IMG_1314_MOD.jpg" width="300" height="225" class="rotate90"/>
jhead -autorot on your JPG image. That's what I do to handle autorotation before putting my images on the web.
This will rotate the image as specified by the camera's orientation sensor, then reset the orientation flag so that it will not be accidentally rotated again.
(Note, I never autorotate my originals, just the scaled versions as part of my script for sending them to the web.)