Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 174761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:34:50+00:00 2026-05-11T13:34:50+00:00

I have a standard Google Apps account. I have setup a custom domain through

  • 0

I have a standard Google Apps account. I have setup a custom domain through Google Apps. I am able to send and receive emails successfully through Google Apps when I use the Gmail interface. However, I want to send an email via code. In order to attempt this, I have been trying the following code:

MailMessage mailMessage = new MailMessage(); mailMessage.To.Add("someone@somewhere.example"); mailMessage.Subject = "Test"; mailMessage.Body = "<html><body>This is a test</body></html>"; mailMessage.IsBodyHtml = true;  // Create the credentials to login to the gmail account associated with my custom domain string sendEmailsFrom = "emailAddress@mydomain.example"; string sendEmailsFromPassword = "password"; NetworkCredential cred = new NetworkCredential(sendEmailsFrom, sendEmailsFromPassword);  SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587); mailClient.EnableSsl = true; mailClient.DeliveryMethod = SmtpDeliveryMethod.Network; mailClient.UseDefaultCredentials = false; mailClient.Timeout = 20000; mailClient.Credentials = cred; mailClient.Send(mailMessage); 

When the Send method is reached, an Exception is thrown that states:

"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."

How do I send emails through my custom domain via Google?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:34:50+00:00Added an answer on May 11, 2026 at 1:34 pm

    There is no need to hardcode all SMTP settings in your code. Put them in web.config instead. This way you can encrypt these settings if needed and change them on the fly without recompiling your application.

    <configuration>   <system.net>     <mailSettings>       <smtp from="example@domain.example" deliveryMethod="Network">           <network host="smtp.gmail.com" port="587"               userName="example@domain.example" password="password"/>       </smtp>     </mailSettings>   </system.net> </configuration> 

    End when you send email just enable SSL on your SmtpClient:

    var message = new MailMessage("navin@php.net"); // here is an important part: message.From = new MailAddress("example@domain.example", "Mailer"); // it's superfluous part here since from address is defined in .config file // in my example. But since you don't use .config file, you will need it.  var client = new SmtpClient(); client.EnableSsl = true; client.Send(message); 

    Make sure that you’re sending email from the same email address with which you’re trying to authenticate at Gmail.

    Note: Starting with .NET 4.0 you can insert enableSsl="true" into web.config as opposed to setting it in code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I signed up with Google apps standard edition for one of my domain names
I have a standard form controller to update a google protocol buffers message object
I have a class based on google.maps.OverlayView which implements a custom replacement for a
Many languages have standard repositories where people donate useful libraries that they want others
I have a standard windows server that inherits from the ServiceBase class. On the
I have a standard .NET windows service written in C#. Can it install itself
I have a standard MOSS 2007 Web Site (MOSS Terminology: Application and a SiteCollection)
I have some standard-texts, but some portion of it is different. But of these
I have a standard ASP.NET MVC (RC Refresh) web project, with the standard ASP.NET
At work I have a standard desk (4 legs, flat surface, you get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.