prob4567 Posted September 6, 2012 Posted September 6, 2012 BHHi, i've wrote a code to send email through the website. It works fine in Network Solutions hosting, but not in heliohost.org. My code is below. The form is located at http://www.crystalclear.heliohost.org/contactus.aspx. What could be causing it? Thanks so much.using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Net.Mail;namespace WebApplication5{ public partial class contactus : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e){} protected void Button1_Click(object sender, EventArgs e){ string bodystring = "Name: " + TextBox1.Text + " Email: " + TextBox2.Text + " Message: " + TextBox3.Text;SendMail(TextBox2.Text, bodystring);Response.Redirect( "thankyou.aspx");Response.Flush();} private void SendMail(string from, string body){ MailMessage message = new MailMessage("myemail@hotmail.com", "sendtoemail@hotmail.com", "Contact From Website", body); SmtpClient mailClient = new SmtpClient("smtp.live.com", 25);System.Net. NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("myemail@hotmail.com", "mypassword");mailClient.DeliveryMethod = System.Net.Mail. SmtpDeliveryMethod.Network; mailClient.UseDefaultCredentials = false;mailClient.EnableSsl = true;mailClient.Credentials = SMTPUserInfo;mailClient.Send(message);message.Dispose();}}}
Shinryuu Posted September 6, 2012 Posted September 6, 2012 The code is sound, and it works on NS you said, I have this strong suspicion that changing: mailClient.EnableSsl = true; to: mailClient.EnableSsl = false; will be the magic solution.
prob4567 Posted September 6, 2012 Author Posted September 6, 2012 BH.Hi Shynryuu, thanks so much for your reply. I've tried changing the enableSsl = false, but in that case i get an exception that something like "must issue starttls command first". Any other suggestions?ThanksAron
Shinryuu Posted September 7, 2012 Posted September 7, 2012 I think you should switch the port number to 587, if that doesn't help I'm not really sure what does, that seems to be a common error with no clear-cut solution. In the event it still gives an error, check your MX records and if those are good I'll just try to write up a slightly easier alternative.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now