Smtp Relay

1,286 views
Skip to first unread message

David Eng

unread,
Oct 30, 2020, 9:17:56 AM10/30/20
to GAM for G Suite
Hi,

i have a set up a smtp relay on gsuite to allow nor...@domain.com to send scripting notification

Here what i have done : 

Authorized senders: Only my domain addresses
Accept only messages from specified IP addresses: Yes
Allowed IP addresses: IPs Test
SMTP authentication required: Yes
Require TLS encryption: Yes 

it doesn't seems to be working when i try to send an email 
command : 

Send-MailMessage -From nor...@domaintest.com-to "to...@domaintest.com" -SmtpServer "smtp.gmail.com" -Subject "test" -Body "Test" -port "587" -UseSsl -Credential 

Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at
At line:1 char:1

any idea ? 


Jay Lee

unread,
Oct 30, 2020, 9:30:20 AM10/30/20
to google-ap...@googlegroups.com
Well this isn't quite GAM related but...

Doesn't look like your client is authenticating properly. The -Credential parameter seems to send your Windows admin credentials by default which is unlikely to work against the Google SMTP server. Seems like you need to specify credentials to use:


--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/9256f683-14d7-40bd-97d1-2d0638434911n%40googlegroups.com.

Gabriel Clifton

unread,
Oct 30, 2020, 9:42:03 AM10/30/20
to google-ap...@googlegroups.com
With Powershell, I usually do
$smtp = "smtp.gmail.com" # This is your SMTP Server
$to1 = "1...@domain.com" # This is the recipient smtp address 1
$to2 = "2...@domain.com" # This is the recipient smtp address 2
$to3 = "3...@domain.com" # This is the recipient smtp address 3
$smtpUsername = "authent...@domain.com"  
$smtpPassword = "password"  
$credentials = new-object Management.Automation.PSCredential $smtpUsername, ($smtpPassword | ConvertTo-SecureString -AsPlainText -Force)
$from = "<fr...@domain.com>" # This will be the sender's address
$subject = "Subject of email"
$MsgBody = "Body of email"

send-MailMessage -SmtpServer $smtp -Port 587 -UseSsl -Credential $credentials -To $to1, $to2, $to3 -From $from -Subject $subject -Body $MsgBody -BodyAsHtml -Priority high

Always works.




--



Gabriel Clifton | Network Administrator

Fort Stockton ISD | Technology Center
gabriel...@fsisd.net | http://www.fsisd.net
Office (432) 336-4055 ext 2

Fax (432) 336-4050
1204 W. Second St., 
Fort Stockton, TX 79735

CONFIDENTIALITY NOTICE: The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited.

"You must always be willing to work without applause."
— Ernest Hemingway

"You just have to find that thing that's special about you that distinguishes you from all the others, and through true talent, hard work, and passion, anything can happen."
— Dr. Dre

David Eng

unread,
Oct 30, 2020, 10:05:01 AM10/30/20
to google-ap...@googlegroups.com
Gabriel, 

I have tried and this is what i get 

send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at
At line:14 char:1
+ send-MailMessage -SmtpServer $smtp -Port 587 -UseSsl -Credential $cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage


by the way i want to send from a noreply@..com to a specific groups ou users

any idea? 

You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/qJdE3gDkttM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/CAJXDcnuBfyT%3DBpWgatym%2BoT3nv395EZWCX9nBpKpX%2BcOEzxqTA%40mail.gmail.com.

Gabriel Clifton

unread,
Oct 30, 2020, 10:40:39 AM10/30/20
to google-ap...@googlegroups.com
OK, check your Admin Console and make sure that the user has rights to send mail by SMTP.

David Eng

unread,
Oct 30, 2020, 10:52:50 AM10/30/20
to google-ap...@googlegroups.com
Done it was disabled 

I have allow it how long does it takes to replicate ? 

that is in : admin.google.com >>Apps > G Suite > Settings for Gmail > End user access > Allow per-user outbound gateways
  right? 

Gabriel Clifton

unread,
Oct 30, 2020, 11:01:56 AM10/30/20
to google-ap...@googlegroups.com
Google can take anywhere from a few minutes to 24 hours for some settings.

David Eng

unread,
Oct 30, 2020, 11:56:51 AM10/30/20
to google-ap...@googlegroups.com
Got it 

I will try and let you know 
hopefully it will work 

David Eng

unread,
Oct 31, 2020, 11:31:20 AM10/31/20
to google-ap...@googlegroups.com
Gabriel, 

I have tried but still not working... any thoughts?

Error : 


send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at
At line:14 char:1
+ send-MailMessage -SmtpServer $smtp -Port 587 -UseSsl -Credential $cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
 

Gabriel Clifton

unread,
Oct 31, 2020, 6:41:06 PM10/31/20
to google-ap...@googlegroups.com
Sorry, that is all I can think of right now. 

Message has been deleted

David Eng

unread,
Nov 6, 2020, 2:01:58 PM11/6/20
to google-ap...@googlegroups.com
Yes, i figured it out 

thanks guys for the help.

Le mar. 3 nov. 2020 à 19:46, Brian Kim <the.br...@gmail.com> a écrit :
Have you enabled less secure app access on admin console and on the account?

It's not recommended. SMTP with OAuth would be a much better solution. 
Another solution is to enable 2FA on the account you are using and use app-specific passwords. But not sure about timeline of Google unsupporting legacy authentication methods (less secure access, i.e username/password combination that does not support modern authentication like SSO or 2FA). 

Ross Scroggs

unread,
Nov 6, 2020, 2:07:27 PM11/6/20
to google-ap...@googlegroups.com
David,

Please share your solution.

Ross



--
--
Ross Scroggs

David Eng

unread,
Nov 17, 2020, 7:22:54 AM11/17/20
to google-ap...@googlegroups.com
Guys, 

In my case 

I had MFA set up, so i have created a an app password 
If there no MFA you will need to enable less secure app to allow request to their smtp 

you might as well need to configure smtp relay and allow which desired ip's and domain. 

David,

Gabriel Clifton

unread,
Nov 17, 2020, 7:32:30 AM11/17/20
to google-ap...@googlegroups.com
Or what I did for a smtp account is create an account completely segregated from all your others, remove permissions from everything like no Gmail no drive no youtube no 2fa, and use a password generator to create a password with the max characters allowed so that everything is completely random. If the account is never used for anything you will minimize it's exposure to the outside world and with a super long random password there is little chance of it being compromised. 

Reply all
Reply to author
Forward
0 new messages