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.
3/7/2009 11:11:37 AM
Gravatar
Total Posts 18409

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 18409

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 18409

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 18409

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.