在asp.net中发送电子邮件的问题 [英] problem in send emails in asp.net

查看:129
本文介绍了在asp.net中发送电子邮件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在发送电子邮件时遇到问题...

我有一个正在使用system.net.mail命名空间的应用程序
当我在系统中的Visual Studio中运行我的应用程序时,它运行正常..
但是当我将网站上载到服务器时,它会产生问题,当我从那里使用我的网站时,电子邮件却无法发送..非常奇怪的问题是整个网站都可以正常工作,除了这个问题...


i have a problem in sending emails...

i have a application i am using system.net.mail namespace
when i run my application in visual studio in my system its working perfectly..
but when i uploaded my site to server it creates problem emails are not sending when i use my site from there.. its very strange problem whole site working perfectly except this problem...


using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Mail;
using System.Net.Mail;


public class EmailManagment
{
    SmtpClient client = new SmtpClient();
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("emailus@eventsitsolution.com", "mypassword");

    public void sendemail(string sendto, string subject, string body)
    {
        try
        {
            client.Host = "smtpout.secureserver.net";
            client.Port = 80;
            client.UseDefaultCredentials = false;
            client.Credentials = credentials;
            client.EnableSsl = false;
            // convert strings to mail address
            MailAddress to = new MailAddress(sendto);
            MailAddress from = new MailAddress("emailus@eventsitsolution.com");
            //
            msg.Subject = subject;
            msg.Body = body;
            msg.To.Add(to);
            msg.From = from;
            msg.IsBodyHtml = true;
     
            client.Send(msg);
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }
}





when i want to send email i just call send email method.

推荐答案

可能是因为您的电子邮件服务器不允许中继.
It''s probably because your email server doesn''t allow relays.


这篇关于在asp.net中发送电子邮件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆