[56K WARN] Newbie At Mailing Via PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

[56K WARN] Newbie At Mailing Via PHP?

Post by guest »

I have created this script.
A contact form, when submitted, will send a confirmation email to the sender

But... It Doesn't, It Reports This Error
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\apache\xampp\htdocs\codeandgames\Contact\SendConfirmation.php on line 41
There was an error sending the e-mail.
STMP Is Enabled (Xampp Says So)
[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
sendmail_from = postmaster@localhost

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
Please Help Me!!!



Contact Form - SendMail Part Is Below
NOTE : All Required Variables Are Recieved

Code: Select all

<?php
require_once "../Settings.php";
$time = $_REQUEST&#1111;"id"];
$boundary = "==MP_Bound_xyccr948x==";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: multipart/alternative; boundary="$boundary"\n";
$headers .= "From: donotreply@codeandgames.com\n";
$html_msg .= '<table align="center" border="1" cellpadding="8">';
$html_msg .= '<tr>';
$html_msg .= '<th>';
$html_msg .= 'Message';
$html_msg .= '</th>';
$html_msg .= '</tr>';
$html_msg .= '<tr>';
$html_msg .= '<td>';
$html_msg .= $_REQUEST&#1111;"message"];
$html_msg .= '</td>';
$html_msg .= '</tr>';
$html_msg .= '</table>';
$confirmsubject = "Please Confirm Your Email To 'Code And Games'";
$confirmmessage = "<center>";
$confirmmessage .= "Please click on the link below to send your message:\n\n";
$confirmmessage .= '<a href="'.$emailconfirmdir.'confirmmail.php?id=$time">Click here to confirm</a>';
$confirmmessage .= '\n<BR><BR>\n<BR><BR>\n';
$confirmmessage .= $html_msg;
$textconfirm = "Please Confirm Your Email To 'Code And Games'";
$textconfirm .= "\n";
$textconfirm .= "Click On The Link Below";
$textconfirm .= "\n\n";
$textconfirm .= $emailconfirmdir."confirmmail.php?id=$time";
$message = "This is a Multipart Message in MIME format\n";
$message .= "--$boundary\n";
$message .= "Content-type: text/html; charset=iso-8859-1\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $confirmmessage . "\n";
$message .= "--$boundary\n";
$message .= "Content-Type: text/plain; charset="iso-8859-1"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $textconfirm . "\n";
$message .= "--$boundary--";
$mailsent = mail($_REQUEST&#1111;"Email"], $confirmsubject, $message, $headers);
if ($mailsent) &#123;
?>
Due To Security
<BR>
We Have To Confirm That Your Email-Adress Is Valid.
<BR><BR>
Please Check Your Email, For A Confirmation Message
<BR>
It Could Take 1-20 Minutes To Arrive In Your Inbox - <?php echo $_REQUEST&#1111;"Email"]; ?>
<?php
&#125; else &#123;
  echo "There was an error sending the e-mail.";
&#125;
?>
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

under what name is Xampp's mail server running :?:
change
SMTP = localhost
to that name.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

What Do You Mean?
How Do I Find Out?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Xampp's admin panel will tell ya what name it is running under.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

Sorry, But I Still Do Not UnderStand

Image
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Just read up something. Xampp for Windows comes with Mercury Mail Transfer System for mailing purposes.
See if THIS solves your prob.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

I Can't See Anthing In That That Will Help Me...
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

change SMTP = localhost to SMTP = smtp. Then try sending mail.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

Still Am Getting The Same Error :

I Have Altered It To :
[mail function]
; For Win32 only.
SMTP = smtp
In
  • * C:\apache\xampp\php\php.ini
    * C:\apache\xampp\php\php4.ini
    * C:\apache\xampp\php\php5.ini
The Executed Contact.php Again.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

Hold On.....

I Looked At This : viewtopic.php?t=30205&highlight=mail

And It Said Use phpinfo() To See Which php.ini Is Being Used.

It Turned Out, It Was Using Yet Anoter php.ini, so i changed thats 'SMTP' value to 'smtp'

It Didn't Work...

So I Changed It To mail.lycos.com as the 'SMTP' and Scottie_Too_Hottie7@lycos.com as the 'sendmail_from'.

But It Still Didn't Work


Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\apache\xampp\htdocs\codeandgames\Contact\SendConfirmation.php on line 41
There was an error sending the e-mail.
Warning: mail() [function.mail]: Failed to connect to mailserver at "mail.lycos.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\apache\xampp\htdocs\codeandgames\Contact\SendConfirmation.php on line 41
There was an error sending the e-mail.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

Here Is The Full Contact Section Code

Message.php

Code: Select all

<?php
echo file_get_contents($_REQUEST&#1111;"file"]);
?>
Types.php

Code: Select all

<?php
$thetypes = Array();
$thevisualtypes = Array();

function AddType($name,$value) &#123;
global $thetypes;
global $thevisualtypes;

$thetypes&#1111;] = Array($name,$value);
$thevisualtypes&#1111;$value] = $name;
&#125;

function EchoTypes() &#123;
global $thetypes;

echo '<select name="type" id="type" size="10">';
echo '\n';
for ($i=0; $i<sizeof($thetypes); $i++) &#123;
echo '<option value="'.$thetypes&#1111;$i]&#1111;1].'"';
if ($_REQUEST&#1111;"type"] == $thetypes&#1111;$i]&#1111;1]) &#123;
echo ' SELECTED';
&#125;
echo '>';
echo $thetypes&#1111;$i]&#1111;0];
echo '</option>';
echo '\n';
&#125;
echo '</select>';
&#125;





AddType("Requests - To Add Something","Additions");
AddType("Requests - Changes","Changes");
AddType("Requests - Removals","Removals");
AddType("","__NA1");
AddType("Login - Problems","Login_Problems");
AddType("Login - Suspended","Login_Suspended");
AddType("","__NA2");
AddType("Programming","Programming");
AddType("","__NA3");
AddType("Other","Other");
?>
SendConfirmation.php

Code: Select all

<?php
require_once "../Settings.php";
$time = $_REQUEST&#1111;"id"];
$boundary = "==MP_Bound_xyccr948x==";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/alternative; boundary="$boundary"\r\n";
$headers .= "From: donotreply@codeandgames.com\r\n";
$html_msg .= '<table align="center" border="1" cellpadding="8">';
$html_msg .= '<tr>';
$html_msg .= '<th>';
$html_msg .= 'Message';
$html_msg .= '</th>';
$html_msg .= '</tr>';
$html_msg .= '<tr>';
$html_msg .= '<td>';
$html_msg .= $_REQUEST&#1111;"message"];
$html_msg .= '</td>';
$html_msg .= '</tr>';
$html_msg .= '</table>';
$confirmsubject = "Please Confirm Your Email To 'Code And Games'";
$confirmmessage = "<center>";
$confirmmessage .= "Please click on the link below to send your message:\n\n";
$confirmmessage .= '<a href="'.$emailconfirmdir.'confirmmail.php?id=$time">Click here to confirm</a>';
$confirmmessage .= '\n<BR><BR>\n<BR><BR>\n';
$confirmmessage .= $html_msg;
$textconfirm = "Please Confirm Your Email To 'Code And Games'";
$textconfirm .= "\n";
$textconfirm .= "Click On The Link Below";
$textconfirm .= "\n\n";
$textconfirm .= $emailconfirmdir."confirmmail.php?id=$time";
$message = "This is a Multipart Message in MIME format\n";
$message .= "--$boundary\n";
$message .= "Content-type: text/html; charset=iso-8859-1\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $confirmmessage . "\n";
$message .= "--$boundary\n";
$message .= "Content-Type: text/plain; charset="iso-8859-1"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $textconfirm . "\n";
$message .= "--$boundary--";
$mailsent = mail($_REQUEST&#1111;"Email"], $confirmsubject, $message, $headers);
if ($mailsent) &#123;
?>
Due To Security
<BR>
We Have To Confirm That Your Email-Adress Is Valid.
<BR><BR>
Please Check Your Email, For A Confirmation Message
<BR>
It Could Take 1-20 Minutes To Arrive In Your Inbox - <?php echo $_REQUEST&#1111;"Email"]; ?>
<?php
&#125; else &#123;
  echo "There was an error sending the e-mail.";
&#125;
?>
Contact.php

Code: Select all

<?php
include("../Login/Valid.php");
include("Types.php");
function GetData($name) &#123;
if ($_REQUEST&#1111;"submitted"] == null) &#123;
return "";
&#125;
else &#123;
return $_REQUEST&#1111;$name];
&#125;
&#125;
$emailsent = true;
$errors = Array();
if (!$_REQUEST&#1111;"submitted"]) &#123;
$emailsent = false;
&#125;
else if($_REQUEST&#1111;"canceledsend"] == "t") &#123;
$emailsent = false;
&#125;
else &#123;
CheckIfEmpty($_REQUEST&#1111;"firstname"],"First Name");
CheckIfEmpty($_REQUEST&#1111;"surname"],"Surname");
//CheckIfEmpty($_REQUEST&#1111;"subject"],"Subject");
CheckIfEmpty($_REQUEST&#1111;"message"],"Message");
ValidEmail($_REQUEST&#1111;"Email"],"E-mail Address");
if ($_REQUEST&#1111;"type"] == null || $_REQUEST&#1111;"type"] == undefined || $_REQUEST&#1111;"type"] == "") &#123;
$errors&#1111;] = "You Didn't Select A Type";
&#125;
if (strpos($_REQUEST&#1111;"type"],"NA") == 2) &#123;
$errors&#1111;] = "You Selected A Blank Type Field";
&#125;

if (sizeof($errors) != 0) &#123;
$emailsent = false;
&#125;
&#125;
if (!$emailsent) &#123;
?>
<HTML>

<HEAD>
<TITLE>Contact Us</TITLE>
<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "../htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")&#1111;1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) &#123; win_ie_ver = 0; &#125;
if (navigator.userAgent.indexOf('Windows CE') >= 0) &#123; win_ie_ver = 0; &#125;
if (navigator.userAgent.indexOf('Opera')      >= 0) &#123; win_ie_ver = 0; &#125;
if (win_ie_ver >= 5.5) &#123;
 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
 document.write(' language="Javascript1.2"></scr' + 'ipt>');  
&#125; else &#123; document.write('<scr'+'ipt>function editor_generate() &#123; return false; &#125;</scr'+'ipt>'); &#125;
// --></script> 
</HEAD>

<BODY BGCOLOR="DDDDDD">


<center>
<h1>Contact Us</h1>

<BR><BR>

<?php
if ($_REQUEST&#1111;"submitted"]) &#123;
?>
<TABLE>
<TR>
<TD>
<?php
for ($i=0; $i<sizeof($errors); $i++) &#123;
$thiserror = $errors&#1111;$i];
?>
<TABLE>
<TR>
<TD align="center" valign="middle">
<img src="Exclamation.gif">
</TD>
<TD align="center" valign="middle">
<B><I><font color="FF8800">
<?php
echo $thiserror;
?>
</font></I></B>
</TD>
</TR>
</TABLE>
<?php
&#125;
?>
</TD>
</TR>
</TABLE>
<BR><BR>
<?php
&#125;
?>

<form name="MyForm" id="MyForm" action="Contact.php" method="post">
<input type="hidden" name="submitted" id="submitted" value="t">
First Name : <input type="text" name="firstname" id="firstname" value="<?php echo htmlspecialchars(GetData("firstname")) ?>">
<BR>
Surname : <input type="text" name="surname" id="surname" value="<?php echo htmlspecialchars(GetData("surname")) ?>">
<BR>
Email-Address : <input type="text" name="Email" id="Email" value="<?php echo htmlspecialchars(GetData("Email")) ?>">
<BR>
Subject : <input type="text" name="subject" id="subject" value="<?php echo htmlspecialchars(GetData("subject")) ?>">
<BR>
<TABLE>
<TR>
<TD>
Type : 
</TD>
<TD>
<?php
EchoTypes();
?>
</TD>
</TR>
</TABLE>

<BR><BR>

Message :
<BR>
<span style="display:none;">
<textarea name="message" id="message"></textarea>
</span>
</form>
<textarea name="mymessage" id="mymessage"><?php echo GetData("message"); ?></textarea>

<script language="JavaScript1.2" defer>
var config = new Object(); // create new config object

config.width = "90%";
config.height = "200px";
config.bodyStyle = 'background-color: #FFFFFF; font-family: "Verdana"; font-size: x-small;';
config.debug = 0;

config.toolbar = &#1111;
  &#1111;'fontname'],
  &#1111;'fontsize'],
  &#1111;'fontstyle'],
  &#1111;'linebreak'],
  &#1111;'bold','italic','underline','separator'],
  &#1111;'strikethrough','subscript','superscript','separator'],
  &#1111;'justifyleft','justifycenter','justifyright','separator'],
  &#1111;'OrderedList','UnOrderedList','Outdent','Indent','separator'],
  &#1111;'forecolor','backcolor','separator'],
  &#1111;'HorizontalRule','Createlink','InsertImage','htmlmode','separator'],
  &#1111;'about','help']
];

editor_generate('mymessage',config);
</script>

<BR><BR>

<script language="JavaScript">
function Submit() &#123;
MyForm.message.innerText = editor_getHTML('mymessage')
MyForm.submit();
&#125;
function Cancel() &#123;
window.close();
&#125;
</script>

<button onclick="Submit()">Submit</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="Cancel()">Cancel</button>


</BODY>
</HTML>
<?php
&#125;
else &#123;
if ($_REQUEST&#1111;"emailsent"] != "t") &#123;
$thetime = time();
$headerfile = "Messages/Tempory/".$thetime.".headers";
$messagefile = "Messages/Tempory/".$thetime.".message";

$hfc_firstname = $_REQUEST&#1111;"firstname"];
$hfc_surname = $_REQUEST&#1111;"surname"];
$hfc_email = $_REQUEST&#1111;"Email"];
$hfc_subject = $_REQUEST&#1111;"subject"];
$hfc_type = $thevisualtypes&#1111;$_REQUEST&#1111;"type"]];
$headerfilecontent = <<<EOF
$hfc_firstname
$hfc_surname
$hfc_email
$hfc_subject
$hfc_type
EOF;

$hf = fopen($headerfile,"w");
fwrite($hf,$headerfilecontent);
fclose($hf);

$mf = fopen($messagefile,"w");
fwrite($mf,$_REQUEST&#1111;"message"]);
fclose($mf);
?>
<HTML>

<HEAD>
<TITLE>Contact Us</TITLE>
</HEAD>

<BODY BGCOLOR="DDDDDD">



<form name="MyForm" id="MyForm" action="Contact.php" method="post" style="display:none;">
<input type="hidden" name="emailsent" id="emailsent" value="t">
<input type="hidden" name="canceledsend" id="canceledsend" value="f">
<input type="hidden" name="submitted" id="submitted" value="t">
<input type="hidden" name="id" id="id" value="<?php echo $thetime; ?>">
First Name : <input type="text" name="firstname" id="firstname" value="<?php echo htmlspecialchars(GetData("firstname")) ?>">
<BR>
Surname : <input type="text" name="surname" id="surname" value="<?php echo htmlspecialchars(GetData("surname")) ?>">
<BR>
Email-Address : <input type="text" name="Email" id="Email" value="<?php echo htmlspecialchars(GetData("Email")) ?>">
<BR>
Subject : <input type="text" name="subject" id="subject" value="<?php echo htmlspecialchars(GetData("subject")) ?>">
<BR>
<TABLE>
<TR>
<TD>
Type : 
</TD>
<TD>
<?php
EchoTypes();
?>
</TD>
</TR>
</TABLE>

<BR><BR>

Message :
<BR>
<textarea name="message" id="message"><?php echo $_REQUEST&#1111;"message"]; ?></textarea>
</form>

<center>
<h1>Contact Us</h1>
<BR><BR>
Please Confirm You Want To Send This Message
<BR><BR><BR><BR>
<TABLE>
<TR>
<TD>
First Name : 
</TD>
<TD>
<?php echo $_REQUEST&#1111;"firstname"]; ?>
</TD>
</TR>
<TR>
<TD>
Surname :
</TD>
<TD>
<?php echo $_REQUEST&#1111;"surname"]; ?>
</TD>
</TR>
<TR>
<TD>
E-mail Address : 
</TD>
<TD>
<?php echo $_REQUEST&#1111;"Email"]; ?>
</TD>
</TR>
<TR>
<TD>
Subject : 
</TD>
<TD>
<?php echo $_REQUEST&#1111;"subject"]; ?>
</TD>
</TR>
<TR>
<TD>
Type : 
</TD>
<TD>
<?php echo $thevisualtypes&#1111;$_REQUEST&#1111;"type"]]; ?>
</TD>
</TR>
</TABLE>

<BR><BR>

<iframe name="messageframe" id="messageframe" src="Message.php?file=<?php echo $messagefile; ?>"></iframe>

<BR><BR>

<script language="JavaScript">
function Send() &#123;
MyForm.submit();
&#125;
function Edit() &#123;
MyForm.canceledsend.value = "t";
MyForm.submit();
&#125;
function Cancel() &#123;
window.close();
&#125;
</script>

<button onclick="Send()">Send</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="Edit()">Edit</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="Cancel()">Cancel</button>



</BODY>
</HTML>
<?php
&#125;
else &#123;
include("SendConfirmation.php");
&#125;
&#125;
?>





Step 1
Image

Image



Step 2
Image



Step 3
Image







!!! PLEASE HELP !!!

Scottie_Too_Hottie7
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

I Know This Is My 4th Post In A Row.

But, Xampp's Own Mail Example Gives The Same Error!
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

guest wrote:But, Xampp's Own Mail Example Gives The Same Error!
8O
I think the error is in the configuration of Xampp/Mercury Server.
Check that out.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

How?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I think you need to seriously think about talking with the xampp guys: http://www.apachefriends.org/f/?language=english
Post Reply