Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MrBilde 13 posts 33 karma points
    Nov 02, 2011 @ 16:08
    MrBilde
    0

    Parameter problem with umbraco.library:SendMail()

    Hi.

    I'm using SendMail and  I've setup the smtp server in the web.config and everything is working fine:

    <xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'subject', 'text', 'false')"/>

    Then I want to make variables for subject and text:

     

      <!--Create text string-->
      <xsl:variable name="text">
        <xsl:value-of select="$name"/>
       (<xsl:value-of select="$company"/>)
        Some body text
      </xsl:variable>

      

      <!--Create subject string-->
      <xsl:variable name="subject">
        <xsl:value-of select="$name"/>
        (<xsl:value-of select="$company"/>)
        Some subject text
      </xsl:variable>

     

    When I only use the $text variable it works fine, and I still receive the email:

    <xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'subject', $text, 'false')"/>

    But if I use both $text and $subject, or $subject only, it doesn't work?

    <xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', $subject, $text, 'false')"/>
    <xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', $subject, 'text', 'false')"/>

     

    Can it be a problem with creation of the variables, or maybe something to do with sendmail?

  • Rich Green 2246 posts 4008 karma points
    Nov 02, 2011 @ 16:11
    Rich Green
    0

    Hi,

    At a complete guess your subject variable is empty and therefore your email is not getting send / or getting sent to you junk mail.

    If you check your Umbraco Log table you'll see that 'umbraco.library:SendMail' reports an error if it fails, no errors means the problem is recieving the email or physically via your smtp server, ie not an Umbraco issue.

    Rich

  • MrBilde 13 posts 33 karma points
    Nov 02, 2011 @ 16:44
    MrBilde
    0

    Hi, I've tested that my $subject variable isn't empty, and also checked my junk mail.

    There's also no entries in the Umbraco log table.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 02, 2011 @ 17:15
    Tom Fulton
    0

    Maybe it's adding a carriage return in the subject since you have it on two lines?  Try condensing it all in one line or possibly wrap it in a normalize-space():

    <xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', normalize-space($subject), $text, 'false')"/>

    But if that was the case I would think you'd get an error in umbracoLog....hmm.  Does your $subject variable work fine if you use it as the email body instead of the subject?

    -Tom

  • MrBilde 13 posts 33 karma points
    Nov 03, 2011 @ 08:52
    MrBilde
    0

    Hi Tom, it didn't help to use $text as subject parameter.

    But normalize-space(): did the trick! thanks!
    But still a bit odd that 1 parameter worked fine, but not both, even if they're the same value?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 03, 2011 @ 13:04
    Tom Fulton
    0

    Hi,

    Glad it worked.

    Even though they were both the same variable, the Subject can't have carriage returns in it.  Because of the way you constructed your variable the subject would actually be:

    Name
    Company
    Some subject text

    Which of course you can't use as a subject.  I imagine you would have an error in your umbracoLog about this.

    normalize-space() will collapse the whitespace so it outputs on one line.

    -Tom

  • MrBilde 13 posts 33 karma points
    Nov 03, 2011 @ 13:59
    MrBilde
    0

    Cheers, I see it clearly now, and yes I also found the error in the umbracoLog :-)

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft