Coding and Gaming
Development Blog Categories (3 Articles)
If you would like to setup a custom email alias for you or your company, please check out this link first: Custom Email Aliases

This article will go over how to setup SMTP for an automatic email generator.
If I am doing this for a client company, I will first setup their Custom Email Alias (with the link above).
I will setup a wildcard for their domain pointing all emails to their inbox...
However, I will also create a "contact" alias pointing to my own inbox, that way I can setup the Email Alias myself and attach it to my own account.
I will verify this new "contact" email on my Gmail account and set it as NOT an alias.
I will also hardcode all "to" values to my email address.
I will then test their SMTP, test my code to generate an email from their domain, and test their contact form, before finally deleting the "contact" alias which will switch everything back over to the client's inbox, and finally changing any "to" values in the code from my email address to their inbox.

That is really the main point of the article, however, I will also include some sample C# code on how I do this:
using (var SmtpServer = new SmtpClient("smtp.gmail.com")) { var mail = new MailMessage { From = from, Subject = subject, IsBodyHtml = true, Body = htmlBody, }; mail.To.Add(to); // Adjust the Reply To mail.ReplyToList.Clear(); mail.ReplyToList.Add(replyTo); SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network; SmtpServer.Credentials = new NetworkCredential("your-email@gmail.com", Password); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); EmailRetryAttempts = 0; return true; }

Permanent Link
If this article helped you, or you have any thoughts on how to do this better, please click the Like button and/or leave a comment below.

Likes: [0]

Comments: [0]






(this is only to show your gravatar icon)



Coming soon blog on AI and ML

Permanent Link
If this article helped you, or you have any thoughts on how to do this better, please click the Like button and/or leave a comment below.

Likes: [0]

Comments: [0]






(this is only to show your gravatar icon)



Automating My Job: Custom Website Generator!


Category
Website Development
Sub Category
AI
Last Updated
2/1/2020
Coming soon blog on AI: Automating My Job

Permanent Link
If this article helped you, or you have any thoughts on how to do this better, please click the Like button and/or leave a comment below.

Likes: [0]

Comments: [0]






(this is only to show your gravatar icon)