Sending email to yahoo account
How do you send an email to a yah开发者_如何学Pythonoo account, I can only send to gmail ? I'd like to know why because MY ISP doesn't offer me a POP3 or SMTP address. I don't know anything about mine, if you could tell me a way to investigate then I'll be delightedly thankful.
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("pevus55@gmail.com", "mypassword");
smtp.EnableSsl = true;
MailAddress mailFrom = new MailAddress("parris797877@yahoo.com");
MailAddress mailTo = new MailAddress("pevus55@gmail.com");
MailMessage msg = new MailMessage(mailFrom, mailTo);
msg.Subject = "Test";
msg.Body = textBox1.Text;
smtp.Send(msg);
You should set your SmtpClient to whatever your outgoing SMTP server is. The code that is successfully sending to GMail is using Google's SMTP server directly. That's OK and is a bit quicker when you're sending to GMail, but they won't want to relay to Yahoo for you. To do so would invite abuse by spammers.
You can find out what your outgoing SMTP server is by looking in the settings of your email client, or by looking at the tech support website for your ISP.
Alternatively you can send directly to yahoo's SMTP server. You'll need to find out what it is. "dig mail.yahoo.com MX" on a *NIX or Mac OS X system will tell you, but to do it automatically you will need to write the code to do a DNS lookup of their MX record.
Some ISPs do not permit outgoing mail to be sent to any SMTP server other than the one that's provided by the ISP. They do that to keep spammers contained. If that's the case you won't be able to talk directly to yahoo's SMTP server, you'll need to talk to your ISPs.
In your code you are using your GMail credentials to connect to the mail server, but see the following.. you are trying to send from Yahoo to GMail.. not from GMail to Yahoo...
MailAddress mailFrom = new MailAddress("parris797877@yahoo.com");
MailAddress mailTo = new MailAddress("pevus55@gmail.com");
If you want to do this you should connect to the Yahoo server with it's credentials..
Thanks...
you need to setup your yahoo email account to allow for that - see these links:
- http://techblissonline.com/yahoo-pop3-and-smtp-settings/
- http://email.about.com/od/accessingyahoomail/f/Yahoo_Mail_SMTP_Settings.htm
- http://help.yahoo.com/l/ca/yahoo/mail/pop/pop-03.html
As SMTP server for Yahoo use smtp.mail.yahoo.com
- please check the SMTP information in the online-help of your Yahoo-account... it provides vital information on how to access Yahoo account via POP3 (get mails) and SMTP (send mails)...
精彩评论