YAFLogo

gost
  • gost
  • 56% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
I can't get SMTP to work. I've checked with my ISP and gotten the right SMTP-server address and port. No login is required to the server. I'm running YAF v1.9.3 final.

Sometimes I get this error in the event log:

System.Threading.ThreadAbortException: Thread was being aborted.
at YAF.Classes.Utils.SendMailThread.SendMailThreaded(Int32 uniqueId)

My web.config looks like this







I've also tried putting this in mail.config but it makes no difference.

Any ideas?
Sponsor

gost
  • gost
  • 56% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
Still no help on this. Anyone?
jshepler
14 years ago
How are you determining that email is not being sent?
not jsheLPer
glynn
  • glynn
  • 59.6% (Neutral)
  • YAF Forumling
14 years ago
gost
  • gost
  • 56% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
jshepler wrote:

How are you determining that email is not being sent?



In the email table in the SQL database I can see that there are several send tries, and no email is received.
jshepler
14 years ago
gost wrote:

In the email table in the SQL database I can see that there are several send tries, and no email is received.



The code that sends the email eats any smtp exception. You can modify the code to log those errors so you can see why it's failing.

YAF.Classes/YAF.Classes.Utils/Mail/SendMail.cs, the SendMailThread class. Find this block of code (~145):
try
{
	// send the email message now...
	System.Diagnostics.Debug.WriteLine( "Sending" );
	SendMail.Send( fromEmailAddress, toEmailAddress, subject, textBody, htmlBody );
	System.Diagnostics.Debug.WriteLine( "Sent" );
}
catch ( System.Net.Mail.SmtpFailedRecipientException )
{
	// only try maximum of 5 times...
	if ( Convert.ToInt32( dt.Rows [i] ["SendTries"] ) < 5 ) deleteEmail = false;
}
catch ( System.Net.Mail.SmtpException )
{
	// only try maximum of 5 times...
	if ( Convert.ToInt32( dt.Rows [i] ["SendTries"] ) < 5 ) deleteEmail = false;
}

change it to:

try
{
	// send the email message now...
	System.Diagnostics.Debug.WriteLine( "Sending" );
	SendMail.Send( fromEmailAddress, toEmailAddress, subject, textBody, htmlBody );
	System.Diagnostics.Debug.WriteLine( "Sent" );
}
catch ( System.Net.Mail.SmtpException x )
{
	// only try maximum of 5 times...
	if ( Convert.ToInt32( dt.Rows [i] ["SendTries"] ) < 5 ) deleteEmail = false;
    YAF.Classes.Data.DB.eventlog_create(1, "SendMailThread", x);
}

* Added catch parameter "x"
* added line to log the exception
* removed redundant SmtpFailedRecipientException catch since it "is a" SmtpException and code didn't do anything different

Notice it only tries 5 times and then removes the email from the queue anyways. You may have to cause another email to be sent so something will get logged.

not jsheLPer
Mek
  • Mek
  • 100% (Exalted)
  • YAF Developer
14 years ago
Your right it should log to the event log errors I think. Will check with Jaben.

UserPostedImage

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
Mek
  • Mek
  • 100% (Exalted)
  • YAF Developer
14 years ago
Comitted to SVN..

Slight change

if (Convert.ToInt32(dt.Rows[i]["SendTries"]) < 5)
                                    deleteEmail = false;
                                else
                                    YAF.Classes.Data.DB.eventlog_create(1, "SendMailThread", x);
Rather than generate an error each time, I'm just creating the eventlog before it removes it forever.

UserPostedImage

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button