问题描述
我敢肯定,这已经被问了,但我还没有找到合适的问题或答案。
I'm sure this has been asked already, but I haven't found the right question or answer yet.
我在Godaddy的一个asp.net网站,我想知道是怎么回事,如果可能的话,送从Gmail电子邮件(或其他域从我有在GoDaddy的不同)的帐户。
I have an asp.net site in Godaddy and what I would like to know is how, if possible, to send an email from a Gmail (or another domain DIFFERENT from the one I have in Godaddy) account.
我有一个虚拟专用服务器和一对夫妇域,但我不希望从一个电子邮件帐户中的任何两个域发送的电子邮件。
I have a virtual dedicated server and a couple of domains, but I don't want the email to be sent from an email account of any of these two domains.
这是我的code:
public static bool _SendMail(string tMailTo, string tSubject, string tBody, string tAttach)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(tMailFrom);
mail.To.Add(tMailTo);
mail.Subject = tSubject;
if (!tAttach.Equals(""))
{
mail.Attachments.Add(new Attachment(tAttach));
}
mail.Body = tBody;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "relay-hosting.secureserver.net";
smtp.Send(mail);
return true;
}
tMailFrom:[email protected]
tMailFrom: [email protected]
我真的不关心,如果它通过GoDaddy或Gmail的,所以我一直在使用smtp.Host =smtp.gmail.com,之后我增加了以下两行,它的工作在本地主机上也试过,但没有工作,一旦上传到Godaddy的:
I really don't care if it goes through Godaddy or Gmail, so I've also tried using smtp.Host = "smtp.gmail.com", and after I added the following two lines, it worked on localhost, but didn't work once uploaded into Godaddy:
smtp.Credentials = new NetworkCredential(smtpUser, smtpPass);
smtp.EnableSsl = true;
我是什么做错了吗?这甚至可能?
而且,我应该怎么改变,如果我想从电子邮件帐户发送另一个域?如果我只是更改SMTP?
What am I doing wrong? Is this even possible?And also, what should I change if I wanted to send from an email account on another domain? Should I just change the SMTP?
谢谢!
推荐答案
我会建议你使用Gmail首先尝试设置一个测试客户端在你的开发机器。只是为了确保GoDaddy的不会阻止任何SMTP流量。
I would recommend you to first try to setup a test client at your development machine using gmail. Just to make sure that godaddy doesn't block any smtp traffic.
我previousely曾与此配置成功:
I previousely had success with this configuration:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network host="smtp.gmail.com" userName="[email protected]" password="password" enableSsl="true" port="587" />
</smtp>
</mailSettings>
只是配置在web.config中,使用SmtpClient类不带参数/性能将得到的web.config配置数据的app.config在Windows中,基础的应用程序。
Just configure it in web.config and use the SmtpClient class without parameters/properties it will get the configuration data from web.config, app.config in windows based applications.
这篇关于使用Goddady Gmail帐户发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!