close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Problem with runtime mail server

Thread began 4/03/2010 1:16 pm by ivanhalen | Last modified 4/20/2010 3:52 pm by Eric Mittman | 1514 views | 12 replies |

ivanhalen

Problem with runtime mail server

Hello,
I'm using the SA Mail Password feature and I found a strange problem...

This works perfectly (hardcoded mail server):
$WA_MailObject = WA_SecurityAssist_Definition("mail.clubnet.tin.it","25","","","","utf-8");

This DOESN'T (runtime mail server; the mail is not sent)
$mailserver = 'mail.clubnet.tin.it';
...
$WA_MailObject = WA_SecurityAssist_Definition("".$mailserver ."","25","","","","utf-8");

On the "Server name" field I insert <?php echo $mailserver; ?>
I'm on IIS 5.0 (Windows XP Pro), if it can help...

This is a non-sense to me: please, have you idea why it is so? Am I wrong in something?
Thanks

Sign in to reply to this post

Eric Mittman

You say that you are inserting <?php echo $mailserver; ?> into the mail server field, have you tried just entering your mail server address here instead? Please post back with the page in question as well as a copy of your Universal Email folder in a zip archive so that we can take a look at it. We should be able to determine why it is not working with the value like this and where you should update it.

Sign in to reply to this post

ivanhalen

Yes, Eric, I wrote it before: when entering a variable that stores my E-mail SMTP server, it doesn't work (and yes, I write <?php echo $mailserver; ?> into the mail server field, and the resulting code is $WA_MailObject = WA_SecurityAssist_Definition("".$mailserver ."","25","","","","utf-8");

When I enter the SMTP server directly (mail.clubnet.tin.it), it works fine
I also printed the $mailserver variable in the HTML body, just to be sure it output the expected value, and it's all fine

I can give you the files, but it's a thing that occurs in the "password retrieval" operation, so I should give you not only the page and the WAAssist folder, but also the database too... DO you need all them?

The installed version of WA Security Assist is 1.1.8

Sign in to reply to this post

Eric Mittman

I want to confirm the details so that I have things straight. You say:

When I enter the SMTP server directly (mail.clubnet.tin.it), it works fine

Does this mean that when you set the value for the mail server within the Universal Email interface that you are entering mail.clubnet.tin.it, or do you mean that when you edit the code and add this in manually that it is working?

I would like to see just the page that has the UE on it to get a better idea for how it looks for you. If you are setting the variable then echoing out the variable it should work all the same. If I have the page in question I might be able to spot an issue or add some debug code to help you get to the bottom of this.

Sign in to reply to this post

ivanhalen

Here's attached a minimal example: just a form, a database and the Mail Password scripts (taken from WA Security Assist)
Plese, swap the mail server between hard-coded and run-time and notice the difference - I added some screenshots, too

Attached Files
mailtest.zip
Sign in to reply to this post

Eric Mittman

I'm not sure why the variable reference is not working for you. To help determine the cause it would be a good idea to print out the value within the helper file to see what is being set for the server during run time.

In your WA_SecurityAssist folder in the Mail_PHP.php file go to line 52 and add in a new line just after this line. In this new line add in this code, it will stop the page from processing and let you know what the mail server is set to at this point.

php:
die("The server name is: " . $serverName);



Please test this out with both the entered value and the variable value to see what you get. Post back with your results.

Sign in to reply to this post

ivanhalen

Here come the problem, Eric!
I get this:

Notice: Undefined variable: mailserver in D:\Web\php\sendmail.php on line 9 The server name is:

But... the variable $mailserver IS defined on line 5 in the file "sendmail.php" :-O

Sign in to reply to this post

ivanhalen

Uh oh, it's a matter of global variable! If I put this on line 9 of "sendmail.php", then it works!

global $mailserver;

The $mailserver variable is defined OUTSIDE the function WA_SecurityAssist_Email_1_SendMail (on line 8), so I have to import it as a global variable

The whole part becomes:

function WA_SecurityAssist_Email_1_SendMail($WA_Auth_Parameter){
global $mailserver;
$WA_MailObject = WA_SecurityAssist_Definition("".$mailserver ."","25","","","","utf-8");
$WA_MailObject = WA_SecurityAssist_SendMail($WA_MailObject,"","","",$WA_Auth_Parameter["toAddress"],"",$WA_Auth_Parameter["fromAddress"],$WA_Auth_Parameter["subject"],$WA_Auth_Parameter["mailBody"]);
$WA_MailObject = null;
}// WA_SecurityAssist_Email_1_SendMail

Ok, this solution works for this particular script... Please, can you give me a way to fix it in the WA Security Assist extensions' files to that I have not to manually fix it each now and then?

Sign in to reply to this post

Eric Mittman

Ok, I see what is going on here. This is a scope issue. The variable you have defined does not have scope inside of the function that is defined on line 8 of sendmail.php. This is a php scope related issue. In order to use a variable inside of a function it must be passed in as a parameter of the function.

The function gets passed the $WA_Auth_Parameter array as the parameter. If you want to use a variable for the mail server like this you would need to add in your variable to the creation of this $WA_Auth_Parameter array that starts on line 16. The values in this array are defined as:

"name" => $value,

So you could add in the mailserver like this:

php:
$WA_Auth_Parameter = array(

    "mailserver" => $mailserver,
    "connection" => $connTest,
      "database" => $database_connTest,
    "tableName" => "users",
    "filterColumn" => "username",



Once you have added it like this you can reference it on line 9 like this:

subject"]

php:
$WA_MailObject = WA_SecurityAssist_Definition($WA_Auth_Parameter["mailserver"],"25","","","","utf-8");
Sign in to reply to this post

ivanhalen

Pretty nice, will this fix be implemented on next WA Security Assist or do I have to manually update scripts in my sites?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...