How to configure sendmail to send email via GMail (smtp.gmail.com), using port 465 or 587?

Solution 1:

Add the following to your sendmail.mc:

define(`RELAY_MAILER_ARGS', `TCP $h 587')
define(`ESMTP_MAILER_ARGS’, `TCP $h 587′)

That should get your outbound mail being sent by Sendmail on port 587.

You'll also need to have sendmail configured to do TLS. It's a bit beyond the scope of your question, but you can find a lot of decent guides about how to do it w/ Google if you're not familiar.