Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Problem regarding the function mail()

the mail() function

Moderators: macek, egami, gesf

Problem regarding the function mail()

Postby azna » Mon May 31, 2004 11:20 pm

hi friends,

Here I need help regarding my mail. I want to reply every email of my visitor who had been sign up in the signbook. But every time I reply the email address of my visitor I got this error :

Warning: mail(): SMTP server response: 503 Need RCPT (no recipients given) in c:\web\mail.php on line 61

I had check all my code and it's ok......so can anybody help me how to resolve it......plzzzzz. I had try change everything about this function but I still got the same problem

plzzz..help me :help:

from,
Azna
azna
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon May 31, 2004 11:01 pm
Location: Malaysia

Postby Alex » Tue Jun 01, 2004 5:00 am

Here is the mail function's description along with prptotype and examples....
Hey can you please post some code, there could be problems with it.
Alex
New php-forum User
New php-forum User
 
Posts: 180
Joined: Fri Mar 07, 2003 4:59 pm

Postby azna » Tue Jun 01, 2004 7:47 am

I had refer in the site that you give it to me....but nothing happen it's still the same error...here is the code for mail.php:

**** -> error line 61

<?php

$wordbits='mailto,mailfrom,mailsub,mailmsg,mailsubmit,mailreset,';
$settings='mailer_is_on,';

//error_reporting(E_ERROR | E_WARNING | E_PARSE);

include('.\root\lib\config.php');

doHeader("$sitename: Public Mailer");

if (getSetting('mailer_is_on')==0) {
showmsg('mailer_is_off');
$buildtime=builtin();
$myspiffytrout=str_replace('<buildtime>', $buildtime, $myspiffytrout);
$myspiffytrout=str_replace('<numberqueries>', $numqueries, $myspiffytrout);
echo $myspiffytrout;
exit();
}

if ($action=='news') $action='mailer';
if ($action=='mailer') {

require('adminfunctions.php');

$inputs[]=formtop('mail.php?action=sendmail');
if (isset($HTTP_GET_VARS['addr'])) {
$inputs[]=inputform('display', $HTTP_GET_VARS['addr'], 'addr');
} else {
$inputs[]=inputform('text', getwordbit('mailto'), 'addr');
}
$inputs[]=inputform('text', getwordbit('mailfrom'), 'from');
$inputs[]=inputform('text', getwordbit('mailsub'), 'subject');
$inputs[]=inputform('textarea', getwordbit('mailmsg'), 'message', '', 70, 10);
$inputs[]=inputform('submitreset', getwordbit('mailsubmit'), getwordbit('mailreset'));

doinputs();
formbottom();

} elseif ($action=='sendmail') {
$to=$HTTP_POST_VARS['to'];
$from=$HTTP_POST_VARS['from'];
$subject=$HTTP_POST_VARS['subject'];
$message=$HTTP_POST_VARS['message'];
$headers="From: $from";
$semi_rand=md5(time());
$mime_boundary="==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"$mime_boundary\"";
$message="This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$message .= "--{$mime_boundary}\n" .
"Content-Transfer-Encoding: base64\n\n" .
"--{$mime_boundary}--\n";


****** $send=mail($to,$subject,$message,$headers);
if ($send) {
showmsg('mailsent');
} else {
showmsg('mailnotsent');
}
}

$buildtime=builtin();
$myspiffytrout=str_replace('<buildtime>', $buildtime, $myspiffytrout);
$myspiffytrout=str_replace('<numberqueries>', $numqueries, $myspiffytrout);
echo $myspiffytrout;

if (getSetting('gzcompress')==1)
ob_end_flush();

?>
azna
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon May 31, 2004 11:01 pm
Location: Malaysia

Postby gesf » Tue Jun 01, 2004 12:34 pm

Try to use the superglobals array ($_GET/$_POST...) in you if´s and else´s (Example):
Code: Select all
<?php
elseif ($_POST['action'] == 'sendmail'){
...
?>


If you don´t know what i´m talking about, please read this!

I recommend you to use it too instead of $HTTP_*_VARS!

Gesf
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Alex » Tue Jun 01, 2004 4:14 pm

Hey if you want something to refer to i beleive i have a post here labled "I guess another mail class" or something close, that has a class you can use to email (i beleive with attatchments) and a few functions that i came up with for SMTP and POP3, but that neednt to be looked over, just look at the class (initial class). Hope that helps...
Also can you tell us the error that you get or at least its number, sometimes it can be something really simple. Ill read through the code whenever i have any time, sort of busy at the time, but i will find time...
reference:
http://us4.php.net/manual/en/ref.mail.php
Alex
New php-forum User
New php-forum User
 
Posts: 180
Joined: Fri Mar 07, 2003 4:59 pm

Postby azna » Tue Jun 01, 2004 5:49 pm

Here is the related fail adminfunction.php that I used in mail.php.....I hope this will help all of you ...
thank you very much

the code :

<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE);

$cpfont="<font size=\"-2\" face=\"verdana\" color=\"#000000\">";

function doinputs()
{
GLOBAL $inputs;
foreach ($inputs as $value) echo $value;
}
function inputform($type, $description, $name='', $value='', $size=50, $maxlength=80)
{
GLOBAL $tdbgcolor,$tdbgcolor,$webroot,$normalfont,$cn,$isadmin,$userid,$layout,$dbr,$formwidth,$textarea_rows;
if ($size==50)
$size=$formwidth;

$commonhtml="\n <tr>
<td bgcolor=\"$tdbgcolor\" width=\"40%\">
$normalfont" .stripslashes($description). "<br />$cn
</td>
<td bgcolor=\"$tdbgcolor\" align=\"top\">\n";
switch ($type) {
case 'text':
$html="\n$commonhtml
<input type=\"text\" name=\"$name\" value=\"$value\" size=\"$size\" maxlength=\"$maxlength\" />
</td>
</tr>\n";
break;

case 'display':
$html="
<tr>
<td bgcolor=\"$tdbgcolor\" colspan=\"2\">$normalfont" .stripslashes($description). "$cn<input type=\"hidden\" name=\"$name\" value=\"$value\" />
$normalfont<b>" .stripslashes($value). "</b>$cn
</td>
</tr>\n";
break;

case 'textarea':
$maxlength=$textarea_rows;
$html="\n$commonhtml
<textarea name=\"$name\" rows=\"$maxlength\" cols=\"$size\" wrap>$value</textarea>
</td>
</tr>\n";
break;

case 'submitreset':
$html="\n$commonhtml
<input type=\"submit\" value=\"$description\" name=\"$value\">
<input type=\"reset\" value=\"$name\">
</td>
</tr>\n";
break;

function formtop($submiturl)
{
GLOBAL $tablebordercolor;
$html="<table bgcolor=\"$tablebordercolor\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" ><tr><td>
<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\">
<form action=\"$submiturl\" method=\"post\" enctype=\"multipart/form-data\">\n";
return $html;
}


?>
azna
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon May 31, 2004 11:01 pm
Location: Malaysia

Postby azna » Tue Jun 01, 2004 6:18 pm

I have tried the code that regarding of the
elseif ($_POST['action']=='sendmail'....
what happen after I changed it...there is no sign that the email is sent or not...

So what I suppose to do...
azna
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon May 31, 2004 11:01 pm
Location: Malaysia

Postby azna » Tue Jun 01, 2004 6:19 pm

I have tried the code that regarding of the
elseif ($_POST['action']=='sendmail'....
what happen after I changed it...there is no sign that the email is sent or not...

So what I suppose to do...
azna
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon May 31, 2004 11:01 pm
Location: Malaysia

Postby gesf » Wed Jun 02, 2004 2:49 am

First, try print/echo your variables to see if there´s something on it, like:
Code: Select all
<?php

$to = $HTTP_POST_VARS['to'];
$from = $HTTP_POST_VARS['from'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];

echo $to;
echo $from;
echo $subject;
echo $message;

?>


Use that the $_POST array in all of your code instead of $HTTP_POST_VARS.

EXample:
Code: Select all
<?php
...

elseif ($_POST['action'] == 'sendmail') {
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];

// In all of your code
// You can try to print/echo this too, to see what´s inside!
...

?>


I don´t know from where some of your variables are coming from , anyway, just a not:

Use $_POST for all of the variables sent through from with method post. Otherwise (form with method get, not sent through form) use $_GET.

So it´s possible that you need to use $_GET in that elseif and in the others witch were not sent through form!
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.