Yahoo Smtp mailsetting configuration - asp.net

Does anyone know what the smtp mail configuration settings are that is needed in the web.config file to send outgoing mail through a form in ASP? Thanks.

Check out this link: Yahoo POP3 and SMTP Settings
My guess is the following should work in your code (not exactly sure about credentials as I do not have an account to test with):
MailMessage mail = new MailMessage();
mail.From = new MailAddress("fromname#somewhere.com");
mail.To.Add("toname#somewhereelse.com");
mail.Subject = "The Subject";
mail.Body = "Body text here";
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com");
smtp.Port = 465; // this could be 587, not sure
smtp.Credentials = new NetworkCredential("YourYahooId", "YourYahooPassword");
smtp.EnableSsl = true; // SSL is required I think
smtp.Send(mail);
The key is to make sure you are using SSL and send authentication credentials. I don't think you will be able to do SSL with just the web.config mail settings. Please see this question for more information.

See the How to utilize Google gmail server in your.NET Web & Windows Applications article. That code work for me. If it doesn't work for you, send mail to me(pandiansaamy#gmail.com)

SMTP_SERVER = "smtp.mail.yahoo.com"
SMTP_PORT = 587
SMTP_USERNAME = "username" // username#yahoo.com
SMTP_PASSWORD = "password"

Related

Email is not sending through MyAsp.Net Server

I am facing some unexpected problem in sending email which i have never faced before. I have hosted my application on the MyASP.NET server.
My Email Domain is purchased from VERIO.
I am sending mails using by my application, which is hosted on MYASP.NET server.
It means I am trying to connect VERIO SMTP server for sending mails from MYASP.NET server.
It is not giving me any error on sending mail click button from my application. but also email is not going to recipient.
The code which I am using are as follows:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("museum#essenrfid.net");
mail.To.Add(txtTo.Text);
//set the content
mail.Subject = "Test Subject";
mail.Body = "TEst Contect";
//send the message
SmtpClient smtp = new SmtpClient("smtp.verio.com", 587);
smtp.EnableSsl = true;
//IMPORANT: Your smtp login email MUST be same as your FROM address.
NetworkCredential Credentials = new NetworkCredential("XXXXx", "XXXXX");
smtp.Credentials = Credentials;
smtp.Send(mail);
NOTE: My email was working till yesterday from last one month but I have not changed code & it was not working from yesterday. What could be the issue. Any Idea anyone faced this problem before.
Please help.
Thanks In advance.

Sending email from website WITHOUT using Google SMTP

I am producing a website for a friends company and they would like customers to be able to contact them using a form on the website that will email the query to their work email address.
All the examples I have been able to find use GMail's SMTP server. I have managed to get this to work using the code below but e-mails always appear in the inbox as from the GMail account, regardless of what I set mm.From to be. I understand that this is the downside to using GMail's SMTP server.
Dim mm As MailMessage = New MailMessage()
mm.From = New MailAddress("customer#test.com")
mm.Subject = "Test Email"
mm.Body = "<p>This is a test email</p>"
mm.IsBodyHtml = True
mm.To.Add(New MailAddress("info#myCompany.com"))
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
Dim NetworkCred As NetworkCredential = New System.Net.NetworkCredential()
NetworkCred.UserName = "mycompany#gmail.com"
NetworkCred.Password = "myPassword"
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
Try
smtp.Send(mm)
Catch ex As Exception
Response.Write(ex)
End Try
I would like the senders e-mail address to appear in the from field so users can just click reply when a message comes in.
The business e-mail account they have is provided by GoDaddy and I have tried entering the SMTP and account details in the code but I get the following error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
Any help would be greatly appreciated.
Thanks
You can use any SMTP service that you have access to. So if GMail's doesn't do what you need, try another one. (The settings for that other one may be different, check with the service host for details.)
However, one thing you can definitely do in your code is set a ReplyTo address. From is only one header in the message, there are others that can be used. A ReplyTo header tells the email client that replies should be sent to a given email address.
mm.ReplyTo = New MailAddress("customer#test.com")

Sending emails using VB code

Not sure if this question has been asked elsewhere...
For a website project that I'm working on, I created an ASPX web form that will send an email containing the contents of the form on button click. I tried it and it worked when I'm using the Yahoo SMTP server and testing using my personal Yahoo email address (+ specifying the username and password).
However, it wouldn't work when I'm using the SMTP server for mail messages for the website (after I've created a new admin email account in the website).
The website is up and running and I'm able to send an email to the website's admin email account (through Yahoo) but just not when sending through the ASPX web form.
Here is the code for using the Yahoo SMTP server and it works fine:
SmtpServer.Credentials = New Net.NetworkCredential("username#yahoo.com", "password")
SmtpServer.Port = "25"
SmtpServer.Host = "smtp.mail.yahoo.com"
mail.From = New MailAddress("username#yahoo.com")
mail.To.Add("username#yahoo.com")
mail.Subject = "RE: Message Subject"
mail.Body = "Message goes here."
SmtpServer.Send(mail)
Now, here is the code for using my website's SMTP server which doesn't work:
SmtpServer.Port = "25"
SmtpServer.Host = "127.0.0.1"
mail.From = New MailAddress("admin#awesomewebsite.org.au")
mail.To.Add("admin#awesomewebsite.org.au")
mail.Subject = "RE: Message Subject"
mail.Body = "Message goes here."
SmtpServer.Send(mail)
These are the correct port and host numbers given by the web hosting company that hosts the website. They also said that username and password are not needed. I also tried appending this to the beginning of the code but it still wouldn't work:
SmtpServer.Credentials = New Net.NetworkCredential()
or even
SmtpServer.Credentials = New Net.NetworkCredential("", "")
I really don't know what to do. Please help this newbie out. Any response is appreciated.
By the way, the error message that I get when I test this out appears in a message box: "Failure sending mail."
You need to create an email account in your web site and use those credentials to send the mail just as you did with yahoo (This can be done in your admin portal of the website but some hosting providers will charge you separately for the email service). Further more the correct smtp server is also should be given, that depends on your hosting provider. You can get that information from your hosting provider. 127.0.0.1 will not work here anyway.
Don't import 'System.Net.Mail'.
Completed code is shown below:
Dim SmtpServer As New Net.Mail.SmtpClient
Dim mail As New Net.Mail.MailMessage
SmtpServer.Host = "198.154.99.8"
SmtpServer.UseDefaultCredentials = False
SmtpServer.Credentials = New System.Net.NetworkCredential("admin#awesomewebsite.org.au", "password")
mail.From = New Net.Mail.MailAddress("admin#awesomewebsite.org.au")
mail.To.Add("admin#awesomewebsite.org.au")
mail.Subject = "RE: Message Subject"
mail.Body = "Message goes here."
SmtpServer.Send(mail)

asp.net send email using gmail on local machine

I am using gmail in my asp.net site to send email. It is working fine on shared server but it donot send email when I run my site on local machine in visual studio. Please guide what should I do to make it sending emails from local machine as well.
thanks
below is my code:
dt = systemrep.GetSystemInfo();
dr = dt.Rows[0];
From = dr["nm_EmailFrom"].ToString();
SMTP = dr["nm_SMTP"].ToString();
Port = dr["amt_Port"].ToString();
EmailId = dr["nm_emailUserId"].ToString();
EmailPassword = dr["nm_emailPassword"].ToString();
DefaultCredations = Convert.ToBoolean(dr["ind_Credentials"].ToString());
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
NetworkCredential mailAuthentication = new NetworkCredential(EmailId, EmailPassword);
message.To.Add(new MailAddress(email.To));
message.From = new MailAddress(From);
message.IsBodyHtml = true;
message.Subject = email.Subject;
message.Body = email.Message;
smtp.UseDefaultCredentials = DefaultCredations;
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Host = SMTP;
smtp.Credentials = new NetworkCredential(EmailId, EmailPassword);
smtp.Send(message);
What are you using as your SMTP server? If you are using localhost (which may work on the server), it probably won't work on your local machine.
If you're sending via smtp.gmail.com from your server OK, but the same code doesn't work on your local machine, it's probably a firewall or antivirus problem.
From your local machine, try "telnet smtp.gmail.com 25" and see if you can connect.
Try disabling the firewall and/or antivirus and see if that fixes the problem.

Sending email using ASP.NET I am getting this error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. u6sm344516ibd.6
I have my code like this?
MailAddress to = new MailAddress("xxxxx#gmail.com");
MailAddress from = new MailAddress("xxx#gmail.com");
MailMessage message = new MailMessage(from, to);
message.Subject = "Error Occred in the application:";
message.Body = ex.Message;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
the SMTP server required that you use a secure connection
client.EnableSsl = true;
You could check if setting the EnableSsl property for SmtpClient to true and specifying the credentials would help.
client.EnableSsl = true;
client.Credentials = new NetworkCredential("user", "password");
You will need to set the appropriate properties of the SmtpClient instance to enable TSL/SSL, and set credentials. Check out this for more:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx
Try configuring your SMTP to use port 25 (with SSL).
For gmail Smtp server, use port 587. Port 465 has problems. Make sure you also pass in your correct gmail address and the password that you use with that address/account. Finally, ensure you have set your gmail account to accept connections from other email apps.

Resources