As many people on the boards noted there seems to be an issue when trying to send email from a website hosted on arvixe through the arvixe mail server. I always get this error:"The SMTP server requires a secure connection or the client was not authenticated. The server response was: SMTP authentication is required."
If you plan on using SSL then you need to use port 465. I would suggest not using secure as you are connecting locally and there is no risk in connecting without SSL on port 25 on hsot 127.0.0.1
MailMessage msg = new System.Net.Mail.MailMessage(Globais.email, "firstname.lastname@example.org", "teste1", "teste1"); msg.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential(Globais.email, Globais.emailPass); //here i already used 25, 26, 468, 587 smtp = new System.Net.Mail.SmtpClient("localhost", 25); smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = mailAuthentication; smtp.Send(msg);
System.Net.Mail.MailMessage objMM = new System.Net.Mail.MailMessage();objMM.From = new MailAddress(Globais.email);objMM.To.Add(new MailAddress("email@example.com")); //Note: this To a collectionobjMM.Subject = "My Subject";objMM.Body = "The Body";objMM.IsBodyHtml = true;SmtpClient smtp = new SmtpClient("localhost");smtp.Credentials - new NetworkCredentials(myUsername, myPassword);smtp.Send(objMM);
1. My recipient address was a Gmail account, and the email came in with a [SPAM] warning on the subject line, e.g., "[SPAM] This is a test email." In there anything I can do in my mail/SmptClient configuration to prevent that [SPAM] from appearing there? This code supports a legitimate application with a very small, fixed number of specific and known recipients.
2. Short of encrypting name/pwd, decrypting them into variables in code-behind, and then creating the NetworkCredential from those variables, is there any alternate way to create a network credential WITHOUT having your email name and password visible in plain text within the page code?