Sending mail through SMTP server via Gmail

Alright, so I’ve come here as a last resort hoping to find that last bit of help I need to solve this. I’ve spent the last two days scouring for answers without actually getting anything direct. First off, I’m an amateur at best, and this is all new territory for me when trying to understand these things. I’ll try my best to describe my issue.

On my current virtual server, I’m using Centos 7 with virtualmin installed. I’ve set up the email accounts just fine, and they work well. (I can login using roundcube to send and receive mail just fine as well).

As a convenience to the people who would be using those email accounts, I was trying to do a “send mail as:” through gmail so that they could reply to email coming it as those addresses (as opposed to their own personal gmail).

On Gmail I tried using secured connection on port 587 using TLS

Authentication failed. Please check your username/password. [Server response: Unspecified Error (SENT_EHLO): Unable to send AUTH command over non ssl connection code(0) ]

I’ve double checked to make sure I have the correct username and password (which I do), and tried a couple things to see if anything has worked. Here’s what I’ve done so far, and the fields Gmail is asking for.

SMTP Server: SMTP.domain.com

Username: _________

Password: __________

Port: 25, 465, 587 (as expected)

Secured connection using SSL

Secured connection using TLS

I tried the following …

  • uncommented appropriate lines in the master.cf file
  • restarted servers after editing (of course)

Anyway, that’s what I have so far. It feels like I’m just missing something small in order to get it to work.

PS:You can look at this Screenshot to get the idea

Any help would be much appreciated.
Thanks!

I use gmail’s outgoing all the time.
smtp.gmail.com
port 465
SSL/TLS
Auth method OAuth2
And then your gmail username and password. I use it on my local email client and have tried it on my VPS as well. Make sure you VPS IP is not blacklisted.

Thank you for the reply but my situation is different … actually quite the opposite ,

I want to use the domains I’ve set up inside VirtualMin to send and receive mails from Gmail, see the attachment.

I don’t want to use my Gmail account on another server.

PS: I can login using roundcube to send and receive mails

Looking forward to hear from you.

I guess there is no solution :frowning:

To use each individual account from your domain requires the domain’s MX to be hosted with (in) Google.
Maybe you should elaborate more on the reason you want to use Gmail’s server as the outgoing server? A solution might be available depending on what you’re actually trying to achieve.

Thank you for your response

In Gmail , you can add email addresses that you own and it allows you to receive emails from name@your-domain.com and even send them via the same address , right from gmail.

So you don’t go to your domain and sign-in to roundcube to do it,
All You need to provide the correct settings (SMTP,Port e.t.c)
you dont need domain’s MX to be hosted with (in) Google.

We were doing on Cpanel all the time.

ScreenShot

Try going on that link , there is an attachment (screenshot) that explains what i want to achieve.

PS: From Gmail We want to send&receive mails from name@our-domain.com,
we dont want send name@gmail.com using our VPS , we need the other way around.

This video could give you some idea https://youtu.be/af3X0PKZvio. Just remember instead of email for username probably will be domain admin or name.domain depending how did you set up your email server within Vmin.

Thank you for responding , The video shows want we to do if we were using cPanel , Now how can we achieve this using virtualmin,
We tried name.domain , name , and alot of other variations

Jul 4 15:58:30 #### postfix/smtpd[62532]: connect from mail-vk0-f45.google.com[209.85.213.45] Jul 4 15:58:30 #### postfix/smtpd[62532]: lost connection after EHLO from mail-vk0-f45.google.com[209.85.213.45] Jul 4 15:58:30 #### postfix/smtpd[62532]: disconnect from mail-vk0-f45.google.com[209.85.213.45] where #### - is the hostname

Every time we are ending up with

Authentication failed. Please check your username/password.
[Server response: Unspecified Error (SENT_EHLO): Unable to send AUTH command over non ssl connection code(0) ]

Am I correct that the problem you’re experiencing at the moment, is that when trying to setup your domain in Gmail, that you’ve been unable to get it to send a test email to your Virtualmin server?

From what I understand, when Gmail tries to send a test message to “mail.domain.com”, you’re receiving a message about the server being too slow to respond? (note that smtp.domain.com doesn’t exist by default, I’d suggest using mail.domain.com instead)

If that’s the case, you’d want to ensure that your server is indeed listening on those interfaces.

What is the output of these commands (you can mask the IP’s if you wish):

netstat -an | grep :587 netstat -an | grep :465

If Gmail gives you the choice, you may want to see if it works on port 587… sometimes one works when the other doesn’t.

-Eric

I had the same issue. I am using gmail as email client and added an account to connect to my mail server. I solved the issue by installing let’s encrypt certificate for my domain and in domain SSL management I clicked button “Copy to Postfix”. In gmail account settings I then chose port 465 and SSL and then the email sending worked.