Email configuration - TLS support

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
10/29/2008 6:49:45 AM
Gravatar
Total Posts 88

Email configuration - TLS support

Hi Joe,

I am trying to configure my gmail account and am having big problems. I've been playing around with the settings, using a test contact form and examining the log file. I keep getting this message:

2008-10-29 11:45:06,531 [3860] ERROR mojoPortal.Web.ContactUI.ContactForm [(null)] - 530 5.7.0 Must issue a STARTTLS command first. 5sm4118631eyf.8

I have tried various combinations of Use SSL = Yes / No, Requires Authentication = Yes / No but I always get either the message above or , depending on the exact combo, 504 Authentication failed.

Does Mojoportal support TLS ?

As always, appreciate your help.
Regards,

Leah

10/29/2008 7:16:45 AM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

Hi Leah,

TLS is the same thng as SSL. I just got it to work using my gmail account, and I've updated the documentation with a Gmail example here:

Email Confguration

Best,

Joe

10/29/2008 7:28:16 AM
Gravatar
Total Posts 88

Re: Email configuration - TLS support

I've replicated yours exactly (as far as I can tell) and it still doesn't work for me. I now get this message:

2008-10-29 12:25:34,031 [3680] INFO mojoPortal.Web.Global [(null)] - Global.asax.cs Application_End
2008-10-29 12:25:40,625 [3860] INFO mojoPortal.Web.Global [(null)] - Application Started.
2008-10-29 12:25:55,125 [3860] ERROR mojoPortal.Web.ContactUI.ContactForm [(null)] - 504 Unrecognized authentication type

 

My settings are....

user.config:

<add key="SMTPServer" value="smtp.gmail.com" />
<add key="SMTPRequiresAuthentication" value="true" />
<add key="SMTPPort" value="587" />
<add key="SMTPUser" value="xxx@gmail.com" />
<add key="SMTPPassword" value="xxx" />
<add key="SMTPUseSsl" value="true" />
<add key="SMTPTimeoutInMilliseconds" value="15000" />

web.config:

<system.net>
<mailSettings>
<smtp from="xxxx@gmail.com">
<network
host="smtp.gmail.com"
port="587"
password="xxxx"
userName="xxxx@gmail.com"
/>
</smtp>
</mailSettings>
</system.net>

 

Can you spot anything ?

 

10/29/2008 7:38:26 AM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

It looks right. Are you sure the settings don't exist more than once in user.config? Settings with lower position in the file will trump settings higher in the file.

10/29/2008 8:08:09 AM
Gravatar
Total Posts 88

Re: Email configuration - TLS support

Yep I've checked, they only exist once. The only other item in the user.config related to e-mail is

<add key="NotifyAdminsOnNewUserRegistration" value="true" />

I did notice, in the web.config file the following fields that I haven't done anything to:

<add key="DefaultEmailFrom" value="noreply@yoursite.com" />
<add key="WebMaster" value="noreply@yoursite.com" />

Do they need updating?

I am going to put this aside til tomorrow as I've spent all morning on it with no luck . I've probably missed something really obvious ; fresh eyes tomorrow might help!!

Thanks,

Leah

11/21/2008 2:21:22 AM
Gravatar
Total Posts 2

Re: Email configuration - TLS support

Were you able to get over the 504 error?  I'm receiving the same error, but all my settings appear to be the same...

11/21/2008 2:57:24 AM
Gravatar
Total Posts 88

Re: Email configuration - TLS support

Hi, no I actually haven't gotten back to it yet - I gave up and added it to my to-do list. I was going to try it with the host server's smtp settings to see if that makes any difference (I was previously just doing it on my local machine)

12/19/2008 10:21:04 AM
Gravatar
Total Posts 8

Re: Email configuration - TLS support

I'm getting the same error with GMail. The same credentials works for DNN on the same server. Any help would be greatly appreciated. Thanks!

Error message:
2008-12-19 11:10:00,806 ERROR mojoPortal.Web.ContactUI.ContactForm - 504 Unrecognized authentication type

web.config
<add key="SMTPServer" value="smtp.gmail.com" />
<add key="SMTPRequiresAuthentication" value="true" />
<add key="SMTPPort" value="587" />
<add key="SMTPUser" value="me@domain.com" />
<add key="SMTPPassword" value="password" />
<add key="SMTPUseSsl" value="true" />
<add key="SMTPTimeoutInMilliseconds" value="15000" />
<!-- leave this blank for ascii encoding -->
<add key="SmtpPreferredEncoding" value="" />
<!-- example for Russian encoding
<add key="SmtpPreferredEncoding" value="koi8-r" />
-->

12/19/2008 1:55:00 PM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

I'm sorry to hear you are having this difficulty. I have no explanation why it doesn't work for some people using gmail. It works for me.

All the information I have to offer is already on the Email Configuration page, if I knew any more I would add it there, so if you ever manage to get it solved please let me know what the problem was. I really don't think its anything specific to the mojoportal code. There are lots of possible reasons for it to not work including things like the ip address of the web site is blacklisted as a spammer. Or if the from address is not the same as the account email address.

Best,

Joe

3/7/2009 11:01:20 AM
Gravatar
Total Posts 1

Re: Email configuration - TLS support

I got same issue. I tried on port 465 but looks like GMAIL enforce to use TLS.

Anyone has a fix for this?

3/7/2009 11:11:37 AM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

 Hi,

I'm not sure if this will make a difference, but one thing you can try is change this to true in Web.config/user.config

<add key="DisableDotNetOpenMail" value="false" />

By default we are using the DotNetOpenMail library, but this switch can make it use the built in .NET smtp classes.

It may produce the same result, but its worth a try.

Hope it helps,

Joe

3/13/2009 9:59:45 AM
Gravatar
Total Posts 5

Re: Email configuration - TLS support

<add key="DisableDotNetOpenMail" value="false" /> 

Thank you! This worked for application emails however the system emails are still failing because of the SSL requirement.

I was able to make at least the recover password email work by changing RecoverPassword.aspx.cs:

using mojoPortal.Net;

...

void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
e.Message.Body = e.Message.Body.Replace("{SiteName}", siteSettings.SiteName);
e.Message.Body = e.Message.Body.Replace("{SiteLink}", SiteUtils.GetNavigationSiteRoot());
SmtpSettings smtpSettings = SiteUtils.GetSmtpSettings();
if (smtpSettings.UseSsl)//using SSL requires using smtpSettings
{

System.Net.Mail.SmtpClient smtpSender = new System.Net.Mail.SmtpClient(smtpSettings.Server, smtpSettings.Port);
smtpSender.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpSender.Credentials = new System.Net.NetworkCredential(smtpSettings.User, smtpSettings.Password);
smtpSender.EnableSsl = true;
smtpSender.Send(e.Message);
e.Cancel = true; //stop here so the "built-in" mail routine doesn't run
}
}

It could use a try/catch, I need to read more cause it works on my test server but the webstore dies, schema changes maybe? Anyway that's not realted to this change.

 

3/13/2009 10:39:42 AM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

Hi Voir,

I have integrated your patch in svn trunk. If you are working with the code from svn trunk, just revert your changes then do svn update and rebuild.

Are there other system emails that are not working?

Best,

Joe 

3/19/2009 1:04:20 PM
Gravatar
Total Posts 5

Re: Email configuration - TLS support

Thanks again Joe,

Not sure if there's an email problem yet. This should go into a new thread but I'll post it here anyway.

Semi Related:

I thought register might have an email issue but I found the register link seems to go directly to "Your account has been created." with a continue button. I started with the release and have as you know started using the svn trunk. Anyway no exceptions are thrown and no record is created in mp_Users. Creating a user in the admin area works fine.

Completly unrelated

I'm adding paysimple and plugnpay gateways to the store and found in dbcartoffer.cs->Update() the SqlParameterHelper sph is constructed with a number of parmeters = 10 which throws an exception because only 8 parameters are passed

SqlParameterHelper sph = new SqlParameterHelper(GetConnectionString(), "ws_CartOffers_Update", 10);

The easy fix is

SqlParameterHelper sph = new SqlParameterHelper(GetConnectionString(), "ws_CartOffers_Update", 8);

I opted to go with adding cartGuid to the mix making the number of params =9 in dbcartoffer.cs and updated cartoffer.c->Udate() and the sp ws_CartOffers_Update sp

public static bool Update(
Guid itemGuid,
Guid cartGuid,
Guid offerGuid,
Guid taxClassGuid,
decimal offerPrice,
DateTime addedToCart,
int quantity,
decimal tax,
bool isDonation)
{
SqlParameterHelper sph = new SqlParameterHelper(GetConnectionString(), "ws_CartOffers_Update", 9);
sph.DefineSqlParameter("@ItemGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, itemGuid);
sph.DefineSqlParameter("@CartGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, cartGuid);
sph.DefineSqlParameter("@OfferGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, offerGuid);
sph.DefineSqlParameter("@OfferPrice", SqlDbType.Decimal, ParameterDirection.Input, offerPrice);
sph.DefineSqlParameter("@AddedToCart", SqlDbType.DateTime, ParameterDirection.Input, addedToCart);
sph.DefineSqlParameter("@Quantity", SqlDbType.Int, ParameterDirection.Input, quantity);
sph.DefineSqlParameter("@TaxClassGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, taxClassGuid);
sph.DefineSqlParameter("@Tax", SqlDbType.Decimal, ParameterDirection.Input, tax);
sph.DefineSqlParameter("@IsDonation", SqlDbType.Bit, ParameterDirection.Input, isDonation);
int rowsAffected = sph.ExecuteNonQuery();
return (rowsAffected > 0);

}

/// <summary>
/// Updates this instance of CartOffer. Returns true on success.
/// </summary>
/// <returns>bool</returns>
private bool Update()
{

return DBCartOffer.Update(
this.itemGuid,
this.cartGuid,
this.offerGuid,
this.taxClassGuid,
this.offerPrice,
this.addedToCart,
this.quantity,
this.tax,
this.isDonation);

}

 

USE [MojoPortal]
GO
/****** Object: StoredProcedure [dbo].[ws_CartOffers_Update] Script Date: 03/19/2009 11:01:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER PROCEDURE [dbo].[ws_CartOffers_Update]

/*
Author: Joe Audette
Created: 2007-03-05
Last Modified: 2009-03-17
*/

@ItemGuid uniqueidentifier,
@CartGuid uniqueidentifier, /* cartGuid added */
@OfferGuid uniqueidentifier,
@OfferPrice decimal(15, 4),
@AddedToCart datetime,
@Quantity int,
@TaxClassGuid uniqueidentifier,
@Tax decimal(15,4),
@IsDonation bit


AS
UPDATE [dbo].[ws_CartOffers]

SET

[OfferGuid] = @OfferGuid,
[OfferPrice] = @OfferPrice,
[AddedToCart] = @AddedToCart,
[Quantity] = @Quantity,
[TaxClassGuid] = @TaxClassGuid,
[Tax] = @Tax,
[IsDonation] = @IsDonation

WHERE
[ItemGuid] = @ItemGuid and
[CartGuid] = @CartGuid


 

 

3/19/2009 1:49:38 PM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

Hi,

Thanks for the bug report. I just changed it to 8 params and committed the fix to trunk. There is no need for the cartguid since the ItemGuid is primary key.

If you complete other payment gateways I hope that you will contribute them.

Best,

Joe 

3/23/2009 9:53:39 AM
Gravatar
Total Posts 5

Re: Email configuration - TLS support

I started a thread under contrubute for the gateway(s). Back to the GMail thread, Basically some mail servers that require authentication (like gmail)  rewrite the "from" address as the authenticated user, so by adding replyTo and putting the desired "from" address as the display name the desired effect of having the contact form (or other app) come from the person that sent it rather than the authenticated user.

Mojoportal.net email.cs

public static void SendEmailNormal(
SmtpSettings smtpSettings,
string from,
string to,
string cc,
string bcc,
string subject,
string messageBody,
bool html,
string priority)
{

...

MailMessage mail = new MailMessage();
/* Gmail changes the from address to the authenticated user
    add from as the display name so you see who the message should be from */
MailAddress fromAddress = new MailAddress(from,from);
MailAddress toAddress = new MailAddress(to);

/* For Gmail (or others that rewrite the from address) add replyToAddress so the recipient can click reply on this message and have it go to the sender */
MailAddress replyToAddress = new MailAddress(from,from);
mail.ReplyTo = replyToAddress;

mail.From = fromAddress;
mail.To.Add(toAddress);
 

...

 

3/23/2009 10:17:25 AM
Gravatar
Total Posts 18439

Re: Email configuration - TLS support

Hi Voir,

I've implemented an overload that takes a replyTo address and made the contact form use that overlaod to achieve the same result based on your suggestion. This will be in svn trunk within the next few days.

Thanks,

Joe

You must sign in to post in the forums. This thread is closed to new posts.