...

View Full Version : Email script not functioning properly?



snowdude2004
02-17-2012, 01:57 PM
Basically I have introduced an email script into my system and it is not working when trying to run with WAMP. I have changed my email address and tried to use it immediately without editing anything else or linking to the pages using iframes etc. When I try to send the email I get the following error code.

http://i31.photobucket.com/albums/c376/snowdude2004/contactError.jpg

here is the link to the resource script I used (I used the bottom one).

http://www.html-form-guide.com/contact-form/simple-php-contact-form.html

I'm wondering if this is an error with the code I have or is it the fact I'm testing it with wamp?

mlseim
02-17-2012, 02:17 PM
Those error (deprecation) is telling you that the PHP functions used
will be (or is already) eliminated in the latest version of PHP.

http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php

The split function:
http://php.net/manual/en/function.split.php

split is replaced by using "explode" ...
http://www.php.net/manual/en/function.explode.php

You may just find it easier to locate a more current email script,
or go into the one you have and update the scripting.


.

snowdude2004
02-17-2012, 02:22 PM
Cheers, I'll have a look into it now, If I can get it to work I'll be sure to thank your post :3

snowdude2004
02-17-2012, 02:24 PM
Those error (deprecation) is telling you that the PHP functions used
will be (or is already) eliminated in the latest version of PHP.

http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php

The split function:
http://php.net/manual/en/function.split.php

split is replaced by using "explode" ...
http://www.php.net/manual/en/function.explode.php

You may just find it easier to locate a more current email script,
or go into the one you have and update the scripting.


.

Just looked at the page, the script was only posted a month ago, so I presume its predated for WAMP but would work normally outside of wamp...eerrgghh I hate doing PHP and not having access to the server from home.

mlseim
02-17-2012, 02:29 PM
It wouldn't hurt to use the script but make changes to it.
Outside of WAMP, in the shared webhost world, the same thing will happen eventually.

My webhost is at: PHP 5.3.8

I know for sure that I was getting the "split deprecation" errors .. until I went
through some scripts and made changes. It keeps the PHP programmers in business.

EDIT:
Also, you'll get warnings and notices about using any date or time functions
unless you define your timezone, in either your PHP config file, or in the scripts ...

For myself, I pick the US Central Timezone ...
date_default_timezone_set('America/Chicago');

No big deal, but something to deal with.


.

snowdude2004
02-17-2012, 02:55 PM
Just had a quick look at depreciation code and saw the change over. So had a quick attempt. This was the original code:




original:

return eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $email);
}



Which I replaced with:




New:

return (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i",$email));
}



but by doing this I have now come up with the error below. I presume this code is going to need completely redoing in many sections and i'll be better off making a much more basic mail system with three seperate fields with a mailto function and declare the variables for name, email, header etc?

error:
Please provide a valid email address

mlseim
02-17-2012, 03:19 PM
Seeing this example online ...

// Email mask
if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0)
$errEmail = '<p class="errText">Email must comply with this mask: chars(.chars)@chars(.chars).chars(2-4)</p>';

I notice you're doing "not" ...
!preg_match

Is is supposed to be "not"?


.

snowdude2004
02-17-2012, 03:33 PM
Seeing this example online ...

// Email mask
if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0)
$errEmail = '<p class="errText">Email must comply with this mask: chars(.chars)@chars(.chars).chars(2-4)</p>';

I notice you're doing "not" ...
!preg_match

Is is supposed to be "not"?


.

*slaps self on forehead and goes red* DOH!
Thank you xD

snowdude2004
02-17-2012, 08:14 PM
have changed split to explode and also addressed the eregi issue and now when clicking submit on the form neither errors pop up however mail is now not sent what so ever...what could be wrong now eerrgghh.

Edit:
Here is the completed code I have:
http://www.mediafire.com/?pftg2pk8azuop1n

Inigoesdr
02-19-2012, 01:51 AM
Make sure error reporting is on(see stickies), comment out the redirect so you can see if there is an error, and var_dump() (http://php.net/var_dump) the return from $formproc->ProcessForm() inside of your contact form file so you can see if the mail was sent at all.

snowdude2004
02-19-2012, 01:45 PM
Make sure error reporting is on(see stickies), comment out the redirect so you can see if there is an error, and var_dump() (http://php.net/var_dump) the return from $formproc->ProcessForm() inside of your contact form file so you can see if the mail was sent at all.

My PHP is very limited so I don't quite understand what I need to do, anyway doing what you said about error reporting I put in this code at the top of every php page and it did nothing:


ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting (E_ALL);

and on the contact form page I added this at the bottom of the error reporting:


ob_end_flush();

By adding this bit I then received this error when submitting the form

http://i31.photobucket.com/albums/c376/snowdude2004/contactError2.jpg

snowdude2004
02-19-2012, 04:48 PM
right I deleted the obendflush and then managed to implement var dump which can be seen below:



if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
var_dump($formproc);
{
$formproc->RedirectToURL("thank-you.php");
}
}


By putting this in it is now saying the message has been submitted but no mail is being received on the email address I specified

snowdude2004
02-19-2012, 04:55 PM
also tried putting var dump at the end of the form but above the last bit of javascript. (is it not working because wamp wont recognise JS?)

when putting vardump at the end I get the code below the input:


object(FGContactForm)[1]
public 'receipients' =>
array
empty
public 'errors' =>
array
empty
public 'error_message' => null
public 'name' => null
public 'email' => null
public 'message' => null
public 'from_address' => null
public 'form_random_key' => string 'CnRrspl1FyEylUj' (length=15)
public 'conditional_field' => string '' (length=0)
public 'arr_conditional_receipients' =>
array
empty
public 'fileupload_fields' =>
array
empty
public 'captcha_handler' =>
object(FGSimpleCaptcha)[3]
public 'error_str' => null
public 'captcha_varname' => string 'scaptcha' (length=8)
public 'uniquekey' => string 'KHJhsjsy65HGbsmnd' (length=17)
public 'mailer' =>
object(PHPMailer)[2]
public 'Priority' => int 3
public 'CharSet' => string 'utf-8' (length=5)
public 'ContentType' => string 'text/plain' (length=10)
public 'Encoding' => string '8bit' (length=4)
public 'ErrorInfo' => string '' (length=0)
public 'From' => string 'root@localhost' (length=14)
public 'FromName' => string 'Root User' (length=9)
public 'Sender' => string '' (length=0)
public 'Subject' => string '' (length=0)
public 'Body' => string '' (length=0)
public 'AltBody' => string '' (length=0)
public 'WordWrap' => int 0
public 'Mailer' => string 'mail' (length=4)
public 'Sendmail' => string '/usr/sbin/sendmail' (length=18)
public 'PluginDir' => string '' (length=0)
public 'Version' => string '2.0.4' (length=5)
public 'ConfirmReadingTo' => string '' (length=0)
public 'Hostname' => string '' (length=0)
public 'MessageID' => string '' (length=0)
public 'Host' => string 'localhost' (length=9)
public 'Port' => int 25
public 'Helo' => string '' (length=0)
public 'SMTPSecure' => string '' (length=0)
public 'SMTPAuth' => boolean false
public 'Username' => string '' (length=0)
public 'Password' => string '' (length=0)
public 'Timeout' => int 10
public 'SMTPDebug' => boolean false
public 'SMTPKeepAlive' => boolean false
public 'SingleTo' => boolean false
public 'smtp' => null
public 'to' =>
array
0 =>
array
...
public 'cc' =>
array
empty
public 'bcc' =>
array
empty
public 'ReplyTo' =>
array
empty
public 'attachment' =>
array
empty
public 'CustomHeader' =>
array
empty
public 'message_type' => string '' (length=0)
public 'boundary' =>
array
empty
public 'language' =>
array
empty
public 'error_count' => int 0
public 'LE' => string '
' (length=1)
public 'sign_cert_file' => string '' (length=0)
public 'sign_key_file' => string '' (length=0)
public 'sign_key_pass' => string '' (length=0)

and when I've submitted information it then changes to:


object(FGContactForm)[1]
public 'receipients' =>
array
empty
public 'errors' =>
array
0 => string 'Failed sending email!' (length=21)
public 'error_message' => null
public 'name' => string 'alex' (length=4)
public 'email' => string 'snow_dude2004@yahoo.co.uk' (length=25)
public 'message' => string 'message at 4 51' (length=15)
public 'from_address' => null
public 'form_random_key' => string 'CnRrspl1FyEylUj' (length=15)
public 'conditional_field' => string '' (length=0)
public 'arr_conditional_receipients' =>
array
empty
public 'fileupload_fields' =>
array
empty
public 'captcha_handler' =>
object(FGSimpleCaptcha)[3]
public 'error_str' => null
public 'captcha_varname' => string 'scaptcha' (length=8)
public 'uniquekey' => string 'KHJhsjsy65HGbsmnd' (length=17)
public 'mailer' =>
object(PHPMailer)[2]
public 'Priority' => int 3
public 'CharSet' => string 'utf-8' (length=5)
public 'ContentType' => string 'multipart/alternative' (length=21)
public 'Encoding' => string '8bit' (length=4)
public 'ErrorInfo' => string 'Could not instantiate mail function.' (length=36)
public 'From' => string 'nobody@localhost' (length=16)
public 'FromName' => string 'alex' (length=4)
public 'Sender' => string '' (length=0)
public 'Subject' => string 'Contact form submission from alex' (length=33)
public 'Body' => string '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title></title><meta http-equiv=Content-Type content="text/html; charset=utf-8">
<style>body,.label,.value { font-family:Arial,Verdana; } .label {font-weight:bold; margin-top:5px; font-size:1em; color:#333;} .value {margin-bottom:15px;font-size:0.8em;padding-left:5px;} </style>
</head><body>Submission from 'contact us' form:<p><div class='label'>Name :</div><div class='value'>alex </div>
<div class='label'>Email :</div><div class='va'... (length=803)
public 'AltBody' => string 'Submission from 'contact us' form:Name :alex
Email :snow_dude2004@yahoo.co.uk
Message :message at 4 51
Submit :Submit
IP address of the submitter:127.0.0.1' (length=159)
public 'WordWrap' => int 0
public 'Mailer' => string 'mail' (length=4)
public 'Sendmail' => string '/usr/sbin/sendmail' (length=18)
public 'PluginDir' => string '' (length=0)
public 'Version' => string '2.0.4' (length=5)
public 'ConfirmReadingTo' => string '' (length=0)
public 'Hostname' => string '' (length=0)
public 'MessageID' => string '' (length=0)
public 'Host' => string 'localhost' (length=9)
public 'Port' => int 25
public 'Helo' => string '' (length=0)
public 'SMTPSecure' => string '' (length=0)
public 'SMTPAuth' => boolean false
public 'Username' => string '' (length=0)
public 'Password' => string '' (length=0)
public 'Timeout' => int 10
public 'SMTPDebug' => boolean false
public 'SMTPKeepAlive' => boolean false
public 'SingleTo' => boolean false
public 'smtp' => null
public 'to' =>
array
0 =>
array
...
public 'cc' =>
array
empty
public 'bcc' =>
array
empty
public 'ReplyTo' =>
array
0 =>
array
...
public 'attachment' =>
array
empty
public 'CustomHeader' =>
array
empty
public 'message_type' => string 'alt' (length=3)
public 'boundary' =>
array
1 => string 'b1_c85f9702d8b42058c4995a0b5f985b08' (length=35)
2 => string 'b2_c85f9702d8b42058c4995a0b5f985b08' (length=35)
public 'language' =>
array
'mailer_not_supported' => string ' mailer is not supported.' (length=25)
'provide_address' => string 'You must provide at least one mailer is not supported.' (length=55)
'execute' => string 'Could not execute: ' (length=19)
'instantiate' => string 'Could not instantiate mail function.' (length=36)
'authenticate' => string 'SMTP Error: Could not authenticate.' (length=35)
'from_failed' => string 'The following From address failed: ' (length=35)
'data_not_accepted' => string 'SMTP Error: Data not accepted.' (length=30)
'recipients_failed' => string 'SMTP Error: The following SMTP Error: Data not accepted.' (length=56)
'connect_host' => string 'SMTP Error: Could not connect to SMTP host.' (length=43)
'file_access' => string 'Could not access file: ' (length=23)
'file_open' => string 'File Error: Could not open file: ' (length=33)
'encoding' => string 'Unknown encoding: ' (length=18)
'signing' => string 'Signing Error: ' (length=15)
public 'error_count' => int 1
public 'LE' => string '
' (length=1)
public 'sign_cert_file' => string '' (length=0)
public 'sign_key_file' => string '' (length=0)
public 'sign_key_pass' => string '' (length=0)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum