locked
SPUtility Error occuring when sending email RRS feed

  • Question

  • Hi everyone, i'm having a trouble with a SharePoint, basically we have users registering to our website but they can't receive an email confirmation, we use this method with C# but i dont think its the problem

    public static void SendEmail(string recipient, string subject, string body)
            {
                try
                {
                    SPUtility.SendEmail(SPContext.Current.Web, false, false, recipient, subject, body);

                    Log(string.Format("Enviada notificação '{0}' a '{1}'", subject, recipient), EventLogEntryType.Information);
                }
                catch (Exception ex)
                {
                    Log(string.Format("Cannot send email'{0}' a '{1}': {2}", subject, recipient, ex.Message), EventLogEntryType.Error);
                }
            }

    System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.16.1.136:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at DtyMailSend.MailSend.MailSendUserControl.SendMail(String email, String semail, String dutydate1) at DtyMailSend.MailSend.MailSendUserCo

    Thursday, May 17, 2018 10:38 AM

All replies

  • Hi DominguesPin,

    Have you set the outgoing E-mail setting on SharePoint server through Central Administration.

    Open Central Administration -> System Settings -> OutGoing Email Settings.

    Mention your outbound SMTP server details.

    Before hand try to ping the SMPT server through command prompt.

    =======


    Regards,

    Arif Solkar

    Blog:

    Please remember to mark the replies as answers if they helped.

    Thursday, May 17, 2018 12:33 PM
  • Hi Arif Solkar, the SMTP server is defined and we can ping to it, everything seems good, could it be an issue about the anti virus? we are using bitdefender
    Thursday, May 17, 2018 1:15 PM
  • Possibly yes something has been blocking your access to the SMPT server

    Regards,

    Arif Solkar

    Blog:

    Please remember to mark the replies as answers if they helped.

    Monday, May 21, 2018 10:32 AM