[PHP] [NEWBIE] PEAR Help

2005-02-21 Thread Brett Patterson
Hello all.  I am new to using PEAR, but not so much to PHP.  I was looking
for a little help.

 

I'm trying to get my contact script to work with the PEAR::Mail extension.
So I followed the tutorial on pear.php.net about using the object =
Mail::factory() and then the object::send() method to send the email.  So
after doing that, I get the following code:

Main.php

$recips = $Recip.'; ';

$recips .= $Email;



require_once('config.php');



$headers['From'] = $Name. .$Email.;

$headers['Subject'] = $Subject;

$headers['To'] = $Recip;

$headers['Cc'] = $Email;

 

require_once('Mail.php');

$mail_object = Mail::factory($method, $params);

$mail_object-send($recips, $headers, $message);

if($mail_object != 'TRUE'){

require_once('PEAR.php');

$error = PEAR_Error::toString();

echo b.$error./b;

$_REQUEST['pageid'] = '23';

}

else{

$_REQUEST['pageid'] = '22';

}

 

Config.php

$method = 'smtp';

 

//$params['sendmail_path'] = /usr/sbin/sendmail;

$params['host'] = localhost;

$params['port'] = 25;

$params['auth'] = TRUE;

$params['username'] = ridgeswi;

$params['password'] = **;

The email is not sent to either recipient, and I don't get an error, or if I
do, it has no values:

i.e. [: message= code=0 mode= level= prefix= info=]

 

Anyone see anything wrong?  Is it perhaps that I'm using tabs instead of
spaces for indentation or what?  Thanks for the help.

 

~Brett



[PHP] [NEWBIE] PEAR::Mail Help Please

2005-02-21 Thread Brett Patterson
Hello all.  I am new to using PEAR, but not so much to PHP.  I was looking
for a little help.

 

I'm trying to get my contact script to work with the PEAR::Mail extension.
So I followed the tutorial on pear.php.net about using the object =
Mail::factory() and then the object::send() method to send the email.  So
after doing that, I get the following code:

Main.php

$recips = $Recip.'; ';

$recips .= $Email;



require_once('config.php');



$headers['From'] = $Name. .$Email.;

$headers['Subject'] = $Subject;

$headers['To'] = $Recip;

$headers['Cc'] = $Email;

 

require_once('Mail.php');

$mail_object = Mail::factory($method, $params);

$mail_object-send($recips, $headers, $message);

if($mail_object != 'TRUE'){

require_once('PEAR.php');

$error = PEAR_Error::toString();

echo b.$error./b;

$_REQUEST['pageid'] = '23';

}

else{

$_REQUEST['pageid'] = '22';

}

 

Config.php

$method = 'smtp';

 

//$params['sendmail_path'] = /usr/sbin/sendmail;

$params['host'] = localhost;

$params['port'] = 25;

$params['auth'] = TRUE;

$params['username'] = ridgeswi;

$params['password'] = **;

The email is not sent to either recipient, and I don't get an error, or if I
do, it has no values:

i.e. [: message= code=0 mode= level= prefix= info=]

 

Anyone see anything wrong?  Is it perhaps that I'm using tabs instead of
spaces for indentation or what?  Thanks for the help.

 

~Brett

 



RE: [PHP] weird mail function problem

2005-02-21 Thread Brett Patterson
First off, this is not the most efficient way to send mail as it closes 
reopens connections to the server for each mail.  Look into using PEAR.

Secondly, I would not loop through everything for each email address.  One
way to do it would be to say:

If($email_to != ){
$to = explode(,, $email_to);
$to_email = ;
$i = 0;
While($i=count($to)){
$to_email .= $to[$i];
}
// Now, just create 1 email, and send it to all the names
  $subject = $email_subject;
  $body .= $HTTP_POST_VARS['message'];
  $body .= \n---\n;
$body .= Article Name :;
$body .= \n---\n;
$body .= $Article_Name;
$body .= \n---\n\n;   
$body .= \nStory :\n\n;
$body .= $TheStory; 
$body .= \n\n\n---\n;
$body .= Sent By: .$HTTP_POST_VARS['email_address'].\n;
$header = From: .$HTTP_POST_VARS['email_address'].
.$HTTP_POST_VARS['email_address'].\n;
$header .= Reply-To: .$HTTP_POST_VARS['email_address'].
.$HTTP_POST_VARS['email_address'].\n;
$header .= X-Mailer: PHP/ . phpversion() . \n;
$header .= X-Priority: 1;
  $header .= To: Some [EMAIL PROTECTED]; // Masks To: field
mail($to_email, $subject, $body, $header);
}

That would make more sense, yet still the server load would be huge because
of all the opening and closing of connections.  Look into PEAR::Mail or
using SMTP.

~Brett

-Original Message-
From: Ahmed Abdel-Aliem [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 21, 2005 2:39 PM
To: php-general@lists.php.net
Subject: [PHP] weird mail function problem

hi
i use this code to send email from mysite
but when it sends to some accounts it repeats the body part twice in
the same email while to other accounts it sends the body one time only
can anyone help in that plz ?


if ($email_to != ) {
$to = array();
$to = explode (,, $email_to);
$to_mum = count($email_to);
for ($i=0; $i$to_mum ; $i++){
$to_email = $to[$i];
$subject = $email_subject;
$body .= $HTTP_POST_VARS['message'];
$body .= \n---\n;
$body .= Article Name :;
$body .= \n---\n;
$body .= $Article_Name;
$body .= \n---\n\n;

$body .= \nStory :\n\n;
$body .= $TheStory; 
$body .= \n\n\n---\n;
$body .= Sent By:  .
$HTTP_POST_VARS['email_address'] . \n;
$header = From:  .
$HTTP_POST_VARS['email_address'] .   .
$HTTP_POST_VARS['email_address'] . \n;
$header .= Reply-To:  .
$HTTP_POST_VARS['email_address'] .   .
$HTTP_POST_VARS['email_address'] . \n;
$header .= X-Mailer: PHP/ . phpversion() . \n;
$header .= X-Priority: 1;
mail($to_email, $subject, $body, $header);

-- 
Ahmed Abdel-Aliem
Web Developer
www.ApexScript.com
0101108551

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Sessions and cookies

2005-02-21 Thread Brett Patterson
Well, if you look in your phpinfo() file, you will see a SESSION_TIMEOUT or
SESSION_LENGTH value that is something like 18... different for each
server.

If you hold all your session values in the array, then you can use
session_destory(); as long as session_start() is previous to that.

I am under the impressions that both Sessions and Cookies are stored on the
user end, but I may be wrong.

~Brett

-Original Message-
From: Jacques [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 22, 2005 1:20 AM
To: php-general@lists.php.net
Subject: [PHP] Sessions and cookies

When a session object is created - where is it store? (Perhaps on the 
application server - IIS or Appatche?) Or on a cookking on a user's 
computer?

To destroy the session object (widht all session vairables inside the 
particluar session object) can I use session_destroy();

What is also the default life span of a session object? and can this 
bechanged?

Reagrds

Jacques 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php