Jump to content

Using C# SmtpClient in Lily server


heymolly

Recommended Posts

Hi, I tried to use Lily account to send the mail from google server.
 
The C# code are: 
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.Credentials = new System.Net.NetworkCredential("google_account", "google_password");
smtpClient.EnableSsl = true;
smtpClient.Send(mail);

I already check the send mail account set to allowed google Secure Apps setting.
These SW implementation work well from my local, but Lily server will show below error:
 
System.Net.Mail.SmtpException: 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 System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
   at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
   at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   
I saw the mail send connection need to smtpClient.EnableSsl.
Not sure it is related Lily not allow the SSL connection?
Or maybe I need to set other setting on Lily?
 
Could you please help me? Thanks.
Link to comment
Share on other sites


Hi, this problem already solved.

I change my mail password to to 16 digits and it work well.

 

It's magic before change the password, i can send this mail well but Lily cannot.

Anyway, now Lily account can use SmtpClient to send the mail.  :)

Edited by heymolly
Link to comment
Share on other sites

Gmail is notorious for being picky.

 

Also, it's worth noting that Lily should be able to send mail via tommy's mail server since it does not have one of its own, provided the following conditions are met:

  • The FROM address of your email must be at a domain that's hosted on your account
  • The code sending the email must be running on Lily.
  • The SMTP connection host name should be tommy.heliohost.org.
  • To avoid the mail being refused or marked as spam (Gmail and Microsoft will refuse it, others will typically put in spam bin), you need to do one of the following. You can modify the DNS records for a Lily domain through your cPanel account's DNS zone editor.
    • Add +65.19.143.6 to the SPF records for the domain used for the FROM address - OR -
    • Set your MX records for the FROM address domain to tommy.heliohost.org 
Link to comment
Share on other sites

  • 2 years later...
On 3/14/2021 at 5:44 PM, wolstech said:

Gmail is notorious for being picky.

 

Also, it's worth noting that Lily should be able to send mail via tommy's mail server since it does not have one of its own, provided the following conditions are met:

  • The FROM address of your email must be at a domain that's hosted on your account
  • The code sending the email must be running on Lily.
  • The SMTP connection host name should be tommy.heliohost.org.
  • To avoid the mail being refused or marked as spam (Gmail and Microsoft will refuse it, others will typically put in spam bin), you need to do one of the following. You can modify the DNS records for a Lily domain through your cPanel account's DNS zone editor.
    • Add +65.19.143.6 to the SPF records for the domain used for the FROM address - OR -
    • Set your MX records for the FROM address domain to tommy.heliohost.org 

I am close to purchasing a hosting plan on Tommy (although I would prefer to be on Morty, which isn't available yet). One of the first apps I plan on building is a simple contact form, where the inputs get emailed to my client. Which of the above bullet points still apply to sending email to someone when hosted on Tommy? I use C#.

Link to comment
Share on other sites

C# / .NET will not run on Tommy. Only Lily supports .NET and related technologies because it's the only server running Windows. You can actually have a Johnny + Lily account and you'd still send mail through Tommy using this method. The server you pick for the Plesk account doesn't really matter honestly because it's not even really used. It's only a requirement because back in the cpanel days Lily leaned on those servers for a lot of things. Plesk obviated the need for it for the most part.

That said, the main differences nowadays from what was posted then are that the hostname is now tommy2.heliohost.org, and the IP for the SPF record is now 65.19.141.77.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...