Can't get e-mail to work.

Topics: Business Logic Layer, Controls
Feb 24, 2011 at 5:20 AM

I've used search and read almost all topics related to e-mail. But nothing helped — test button doesn't work, nor the notifications, nor the contact page.

I want to use my Gmail account. For the last few days I've tried any combination of ports with SSL enabled/disabled. Tried to set up login with or without @gmail.com part. But in any case I've got errors.

For port 465 I've got time out error, for port 587 I've got "Failed to send email. Illegal character in the email header."

And for port 25 I've got "Failed to send email. Unable to connect to remote server An attempt to establish a connection was unsuccessful, because from another computer within the required time is not received the desired response or has been disconnected already established connection due to an incorrect response is already connected computer 74.125.43.109:25" (Sorry, text of errors is translated from Russian via Google. Although I've got English in settings, not Auto, it affects only blog interface, but errors are still in Russian.)

I'm running BlogEngine.NET 2.0.0.36 on my home PC, so I do not have any hosting, only DynDNS service. IIS 7.0, .NET Framework 2.0.

Thanks for attention, Roman.

Feb 24, 2011 at 10:08 AM
Edited Oct 24, 2011 at 6:51 PM

Here are the settings you need:

 

UserName@gmail.com
smtp.gmail.com
587
Enable SSL  <---Make sure this is checked

Java Blog

Feb 24, 2011 at 12:52 PM

As I already said, I get an errors with or without SSL checked and on any port. But thanks for reply.

Coordinator
Feb 24, 2011 at 2:05 PM

Most likely email call blocked by firewall, either by your ISP or local.

Feb 24, 2011 at 4:33 PM

> for port 587 I've got "Failed to send email. Illegal character in the email header."

Invalid character for example space char in UserName ?

 

Feb 24, 2011 at 9:01 PM
rtur wrote:

Most likely email call blocked by firewall, either by your ISP or local.

Nope. I'm using Windows Mail client every day to send e-mails via SMTP and receive via both POP3 and IMAP. But to be sure I  turned off Firewal and checked status of port 25 in my account at my ISP site — it's open.

mvincic wrote:

Invalid character for example space char in UserName ?

Re-entered all fields, same. But! For port 25 there's now same error as for 587 — illegal character

Thank you for responses.

Coordinator
Feb 24, 2011 at 9:51 PM

Take a look at SendMailMessage function - this is exactly what BlogEngine uses to send email. If you running locally, you can paste it to simple console application and step through debugger to see where it is failing. And you did try different user name, right? :)

Feb 25, 2011 at 6:26 AM

Sorry, I didn't get what exactly I should do. I'm not a coder.

Yes, I've tried different username, even different e-mail services.

Feb 25, 2011 at 4:42 PM

> Nope. I'm using Windows Mail client every day to send e-mails via SMTP

... and do you send your mails via smtp.gmail.com ?
If so, then you should configure BE.NET in the same way, settings should be as  one kbdavis07 wrote ( SSL, port 587, forget standard port 25).

Please check also that you do not have some control or nonlatinic characters in gmail UserName.

 

Feb 25, 2011 at 8:27 PM
mvincic wrote:

... and do you send your mails via smtp.gmail.com ?
If so, then you should configure BE.NET in the same way, settings should be as  one kbdavis07 wrote ( SSL, port 587, forget standard port 25).

Please check also that you do not have some control or nonlatinic characters in gmail UserName.

 

Yes. In WinMail I use port 465 for both of my gmails. SSL enabled. But in BE.NET 465 gives timeout error after a while and 587 instantly gives error "Failed to send email. Illegal character in the email header."

I heve no nonlatinic characters.

Can I share some thoughts?
This error "<...> already connected computer 74.125.43.109:25" I've tried also russian e-mail service qip.ru and my other gmail acc and it gives me same error with other IPs. I've checked both and this is IPs of servers: google and qip. Can it be some error in the code which cousing wrong request or something? Sorry if it's dumb question.

Thank you.

Feb 25, 2011 at 9:42 PM

 

> This error "<...> already connected computer 74.125.43.109:25"

nslookup 74.125.43.109, port 25 indicates that you are connected to SMTP server of  1e100.net and this might request  1e1000.net email addresses ( not username@gmail.com ) because of spamming.

 > I do not have any hosting, only DynDNS service

Do you use DynDNS MailHop Outbound / SendLabs SMTP ?

Feb 25, 2011 at 11:37 PM

No, I'm not. I'm a free user. This will help? But why my e-mail client works properly? BE.NET e-mail functions are supposed to work on home PC with internet connection? 'Cos I stopped IP updater and reconnected to the internet to change IP and still getting errors.

Feb 27, 2011 at 9:45 AM
Edited Feb 27, 2011 at 9:48 AM

You have to use port 587, please limit discussion to port 587.

Does your WinMail client work with port 587, but BE.NET with same settings ( same username, port 587, SSL enabled ) raise an error ?
If so, firewall on your PC handles WinMail <-> IIS / BE.NET differently,  check firewall rules.

SideNote, why you  have to use port 587 for smtp.gmail.com ? Port 25 has no encryption and Google mandates encryption. 
Ports 465 and port 587 use different encryption techniques and port 587 works fine from BE.NET.

 

 

Feb 27, 2011 at 10:08 AM
Edited Feb 27, 2011 at 10:13 AM

As I said before, I tried to connect when firewall was turned off.

It's the port 587. It gives an errror instantly. It does not even try to connect.

Edit: WinMail works with port 587 well.

Feb 27, 2011 at 12:17 PM

port 587, SSL enabled continued, please

- enable logger BlogEngine extension,
- provoke a problem by clicking "Test email settings" in Admin Panel,
- take a look at ..\App_Data\logger.txt  => search "Error sending email in SendMailMessage: " lines, post them  here.

BE.NET works fine with smtp.gmail.com port 587, SSL enabled setting.

If I use port 465 instead of 587, I find following in logger.txt

"Error sending email in SendMailMessage: The operation has timed out."



 

Feb 27, 2011 at 7:14 PM

Here it is from logger.txt, word by word:

Date: 27.02.2011 22:55:52 Contents Below Error sending email in SendMailMessage: Сбой при отправке сообщения электронной почты. Недопустимый знак в заголовке электронной почты.

As I said before, errors appears in russian even though I've got english set up. Error text translated with Google: "Failed to send email. Illegal character in the email header."

Thanks for your help anyway. If you have any other ideas, please, say, but tomorrow I'll reinstall BE. BTW, what components should I enable in control panel? Maybe I missed something. I've got only static content on my server before that and only basic componets of IIS was enabled. 

Feb 27, 2011 at 9:25 PM
Edited Feb 27, 2011 at 9:53 PM

You should google for "Недопустимый знак в заголовке электронной почты." 
It seems that  .NET 2.0 and 3.5 SmtpClient that does not implement SMTP protocol according to RFC specification and has a problem with russian named computers that use cyrillic letters. 
One solution would be to rename your computer

Please take a look at :

1)   http://brain-it.blogspot.com/2010/03/smtpclient-net-35.html

2) http://forum.sources.ru/index.php?showtopic=276462&st=15

> Все заработало поменял имя компьютера, написал английскими буквами(Романтик->ROMANTIK) и все заработало

3) http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/9c3166d7-ae8d-46f4-b1d3-f51913af41ca/

Last link is an english one, first two are russian.

 

 

Feb 28, 2011 at 10:04 AM

God darn! It's alive! I mean it works. Thank you very much. Any chance to fix it to work with russian charcters in PC name? Like in third link, last post. Or if the code would be same, where to paste it?

Thanks again.

Feb 28, 2011 at 4:20 PM
Edited Feb 28, 2011 at 4:20 PM

FQDN for Home System,

You can put following before <system.web.extensions> in Web.config and take a try with russian chars PC name.

<system.net>
   <mailSettings>
     <smtp>
        <network clientDomain = "yourmachineenglishname" />
    </smtp>
   </mailSettings>
</system.net>

Processing this config entry requires .NET 4.0 or .NET 2.0 MS KB article 957497 .hotfix installed,  see :
http://social.msdn.microsoft.com/Forums/en/netfxnetcom/thread/77f45c5f-76be-400c-a529-a1e49d6d8e62

This article has also a C# SmtpClientEx workauround , but SmtpClientEx requires BE source code change.