Can you do it manually using telnet?
If you can get that working you can probably work it out for yourself.
Remember you’ll need a public domain name to send email to gmail.com
e.g. your server is mail.somedomain.com
here gmail would do a dns lookup on mail.somedomain.com to make sure you
are who you say you are to prevent spoofed mails