php-general Digest 16 Jan 2011 19:37:16 -0000 Issue 7136

Topics (messages 310794 through 310806):

Re: which php file is sending emails?
        310794 by: Nilesh Govindarajan
        310800 by: Marc Guay
        310801 by: Mujtaba Arshad
        310802 by: David Hutto

email list 101
        310795 by: Kirk Bailey
        310796 by: Michelle Konzack
        310797 by: Peter Lind
        310798 by: David Hutto
        310799 by: David McGlone
        310806 by: Jim Lucas

PHP tutorials
        310803 by: tedd
        310804 by: Joshua Kehn
        310805 by: Daniel Brown

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 01/16/2011 12:33 PM, Jim Lucas wrote:
On 1/15/2011 10:51 AM, Nilesh Govindarajan wrote:
On 01/15/2011 11:13 PM, Daniel Brown wrote:
On Sat, Jan 15, 2011 at 12:21, Nilesh Govindarajan<nil...@itech7.com>   wrote:
On 01/15/2011 10:22 PM, Jim Lucas wrote:

Um, I use OpenBSD and that command gives me an error or two...

$ grep -l mail $(find -name *.php)
find: unknown option -- n
find: unknown option -- a
find: unknown option -- m
find: unknown option -- e
formmail.php

$ grep -l mail $(find ./ -name "*.php")
Output a big long list of files...

So the second one is right.

      His point was in the irony --- you sent a rather insulting message
to the OP suggesting he needs to "revise [his] sysadmin skills,"
whereas your own example was broken.  Probably just a typo, but
something worth a second thought for next time.


hahaha, that command wasn't broken. It works on Linux. But certain commands have
to be changed to work on *BSD.

For example, chmod u=rwx,g=rwx,o= directory -R will work on linux, but will not
on FreeBSD. It has to be changed to chmod -R u=rwx,g=rwx,o= directory.


Ok, are you trying to pull our chain here???  Which version of Linux?  I have
tried your example on CentOS release 4.2 (Final), and CentOS release 5.5
(Final), and it gives me this

# grep -l mail $(find -name *.php)
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

and it just sits there waiting for input, just like grep would if I did this

# grep -l mail

I have to surround the name value in quotes to make it work.  Like so...

# grep -l mail $(find -name "*.php")

So, please, within what version of Linux does your example work?

If you are going to give advice and want to contribute good working example code
to the archives of this mailing list, please, for everybody's benefit make sure
the code example works as expected.  Or, if it is to used as a guide to get the
person thinking, say that.

Jim Lucas


LOL. Anyways, we always learn from mistakes. Thanks for correcting me.
Actually I wrote that in a hurry, so didn't test it. Usually I test before writing any code/command on irc/mailing lists.
Apologies friends. :)

--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com

--- End Message ---
--- Begin Message ---
> There can be nothing more simpler than this!!!

I thought that this quote needed some revisiting.

Marc

--- End Message ---
--- Begin Message ---
Nilesh's note to self: don't sound condescending when suggesting untested
code.

On Sun, Jan 16, 2011 at 10:56 AM, Marc Guay <marc.g...@gmail.com> wrote:

> > There can be nothing more simpler than this!!!
>
> I thought that this quote needed some revisiting.
>
> Marc
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Mujtaba

--- End Message ---
--- Begin Message ---
On Sun, Jan 16, 2011 at 11:19 AM, Mujtaba Arshad <mujtab...@gmail.com> wrote:
> Nilesh's note to self: don't sound condescending when suggesting untested


Now define 'self'. Is it a remembrance(i.e. a string of molecular
structures), or a google(google 'Rich formatting' says google isn't
actually a word, and gives the squiggly red underlining for it's own
name) search through the archives?

--- End Message ---
--- Begin Message --- So, in php, I want a program to handle sending out a mail list. All this is going to do is be a filter to exclude non subscribers, and send a copy to every person in the subscriber file. This is pretty simple in python, but this is not my mother tounge we speak here, so let's talk in php instead.

If the submission does not come from a member, the script simply aborts. So the script should read the subscriber file, and if the source From: does not appear there, DIE. If it is there, walk the array and send a copy there, then end.

Now how to do this in php? Is there an off the shelf solution?


--
end

Very Truly yours,
                - Kirk Bailey,
                  Largo Florida

kniht +-----+ | BOX | +-----+ think
--- End Message ---
--- Begin Message ---
Hello Kirk Bailey,

Am 2011-01-16 10:09:03, hacktest Du folgendes herunter:
> So, in php, I want a program to handle sending out a mail list. All
> this is going to do is be a filter to exclude non subscribers, and
> send a copy to every person in the subscriber file. This is pretty
> simple in python, but this is not my mother tounge we speak here, so
> let's talk in php instead.
> 
> If the submission does not come from a member, the script simply
> aborts. So the script should read the subscriber file, and if the
> source From: does not appear there, DIE. If it is there, walk the
> array and send a copy there, then end.
> 
> Now how to do this in php? Is there an off the shelf solution?

Maybe using RTFW <http://www.php.net/>

This is realy basic and you can use shell() with a  shell/grep  line  or
fopen() and read line by line.

Thanks, Greetings and nice Day/Evening
    Michelle Konzack

-- 
##################### Debian GNU/Linux Consultant ######################
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsystems@tdnet France EURL       itsystems@tdnet UG (limited liability)
Owner Michelle Konzack            Owner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz                 Kinzigstraße 17
67100 Strasbourg/France           77694 Kehl/Germany
Tel: +33-6-61925193 mobil         Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

<http://www.itsystems.tamay-dogan.net/>  <http://www.flexray4linux.org/>
<http://www.debian.tamay-dogan.net/>         <http://www.can4linux.org/>

Jabber linux4miche...@jabber.ccc.de
ICQ    #328449886

Linux-User #280138 with the Linux Counter, http://counter.li.org/

Attachment: signature.pgp
Description: Digital signature


--- End Message ---
--- Begin Message ---
On 16 January 2011 16:35, Michelle Konzack
<linux4miche...@tamay-dogan.net> wrote:
> Hello Kirk Bailey,
>
> Am 2011-01-16 10:09:03, hacktest Du folgendes herunter:
>> So, in php, I want a program to handle sending out a mail list. All
>> this is going to do is be a filter to exclude non subscribers, and
>> send a copy to every person in the subscriber file. This is pretty
>> simple in python, but this is not my mother tounge we speak here, so
>> let's talk in php instead.
>>
>> If the submission does not come from a member, the script simply
>> aborts. So the script should read the subscriber file, and if the
>> source From: does not appear there, DIE. If it is there, walk the
>> array and send a copy there, then end.
>>
>> Now how to do this in php? Is there an off the shelf solution?
>
> Maybe using RTFW <http://www.php.net/>

Considering that you've used the PHP list for some very inane
questions yourself, perhaps you should keep the tone lighter and avoid
flaming people? Just a thought.

Regards
Peter

-- 
<hype>
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
</hype>

--- End Message ---
--- Begin Message ---
On Sun, Jan 16, 2011 at 10:43 AM, Peter Lind <peter.e.l...@gmail.com> wrote:
> On 16 January 2011 16:35, Michelle Konzack
> <linux4miche...@tamay-dogan.net> wrote:
>> Hello Kirk Bailey,
>>
>> Am 2011-01-16 10:09:03, hacktest Du folgendes herunter:
>>> So, in php, I want a program to handle sending out a mail list. All
>>> this is going to do is be a filter to exclude non subscribers, and
>>> send a copy to every person in the subscriber file. This is pretty
>>> simple in python, but this is not my mother tounge we speak here, so
>>> let's talk in php instead.
>>>
>>> If the submission does not come from a member, the script simply
>>> aborts. So the script should read the subscriber file, and if the
>>> source From: does not appear there, DIE. If it is there, walk the
>>> array and send a copy there, then end.
>>>
>>> Now how to do this in php? Is there an off the shelf solution?
>>
>> Maybe using RTFW <http://www.php.net/>
>
> Considering that you've used the PHP list for some very inane
> questions yourself, perhaps you should keep the tone lighter and avoid
> flaming people? Just a thought.

But  hypocrisy is so fun though.

>
> Regards
> Peter
>
> --
> <hype>
> WWW: plphp.dk / plind.dk
> LinkedIn: plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: kafe15
> </hype>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Think outside the "sphere"...O

--- End Message ---
--- Begin Message ---
On Sunday, January 16, 2011 10:09:03 am Kirk Bailey wrote:
> So, in php, I want a program to handle sending out a mail list. All this
> is going to do is be a filter to exclude non subscribers, and send a
> copy to every person in the subscriber file. This is pretty simple in
> python, but this is not my mother tounge we speak here, so let's talk in
> php instead.
> 
> If the submission does not come from a member, the script simply aborts.
> So the script should read the subscriber file, and if the source From:
> does not appear there, DIE. If it is there, walk the array and send a
> copy there, then end.
> 
> Now how to do this in php? Is there an off the shelf solution?

Have you tried Majordomo? 

-- 
Blessings
David M.

--- End Message ---
--- Begin Message ---
On 1/16/2011 7:09 AM, Kirk Bailey wrote:
So, in php, I want a program to handle sending out a mail list. All this
is going to do is be a filter to exclude non subscribers, and send a
copy to every person in the subscriber file. This is pretty simple in
python, but this is not my mother tounge we speak here, so let's talk in
php instead.

If the submission does not come from a member, the script simply aborts.
So the script should read the subscriber file, and if the source From:
does not appear there, DIE. If it is there, walk the array and send a
copy there, then end.

Now how to do this in php? Is there an off the shelf solution?



Is this something that you plan on executing with your SMTP server or through a web script?
Do you care how the subscribers file is managed?  If at all...
How is the subscriber file formatted?

With the above questions unanswered, I would do something along the lines of the following.

form.php:
<html>
<form action="process.php" method="post">
INPUT:fromname:value (display name)
INPUT:fromaddr:value (email address)
INPUT:subject:Something special
INPUT:message:the message goes here
</form>
</html>


process.php:
<?php

# Clean input
if (get_magic_quotes_gpc())
    $clean_post = array_map('stripslashes', $_POST);


# Check for required fields
$msg = 'Please press your back button and try again.';
if ( empty($clean_post['fromaddr']) )
        die('From address is required.  '.$msg);
if ( empty($clean_post['subject']) )
        die('Subject is required.  '.$msg);
if ( empty($clean_post['message']) )
        die('Message is required.  '.$msg);

# Error on bad input
if ( !empty($clean_post['fromname']) &&
     strpos($clean_post['fromname'], PHP_EOL) )
        die('Invalid from name.  ' . $msg);
if ( strpos($clean_post['fromaddr'], PHP_EOL) !== false )
        die('Invalid from address.  ' . $msg);
if ( strpos($clean_post['subject'], PHP_EOL) !== false )
        die('Invalid subject.  ' . $msg);

# assuming the format is one email address per line
$subscriber_file = '/path/to/file';

$subscribers = array();
if ( file_exists($subscriber_file) )
        $subscribers = @file($subscriber_file);

# Check for the submitters email address in the subscribers list
if ( !in_array($clean_post['fromaddr'], $subscribers) )
        die('I don't see your email address in this list.  ' . $msg);

# By this point, everything should be checked and you should be ready
# to send your messages

# NOTE: Download and install a copy of phpmailer
# NOTE: the remaining is from the example.php included in phpmailer
# NOTE: I suggest using SMTP auth because it will allow you to generate
#       an email using a 3rd party email address then what is probably
#       allowed by your local mail server.

include '/path/to/phpmailer/class.phpmailer.php';

$mail = new PHPMailer();

$mail->IsSMTP();             // set mailer to use SMTP
$mail->Host = "mail.example.com";  // specify mail server host name
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "<fill this in>";  // SMTP username
$mail->Password = "<fill this in>"; // SMTP password

$mail->From = $clean_post['fromaddr'];
if ( !empty($clean_post['fromname']) )
{
  $mail->FromName = $clean_post['fromname'];
  $mail->AddReplyTo($clean_post['fromaddr'], $clean_post['fromname']);
} else {
  $mail->AddReplyTo($clean_post['fromaddr']);
}
$mail->Subject = $clean_post['subject'];
$mail->Body    = $clean_post['message'];
$mail->AltBody = strip_tags($clean_post['message']);

# add each person
foreach ( $subscribers AS $addr )
{
  $mail->AddAddress($addr);
  # if you have a name associated to that address, do this instead
  # assuming line format as: em...@address.com,My Name
  list($addr, $name) = explode(',', $addr, 2)
  $mail->AddAddress($addr, $name);
}

if(!$mail->Send())
{
  echo "Message could not be sent. <p>";
  echo "Mailer Error: " . $mail->ErrorInfo;
  exit;
}

if ( ! headers_sent() )
  header('Location: http://www.example.com/done.php');

?>

--
Jim Lucas

DISCLAIMER: Unless otherwise noted, all code is untested!

--- End Message ---
--- Begin Message ---
Hi gang:

In the past we talked about PHP tutorials, but I don't remember if there was a single clearinghouse/link for them or not -- is there one? If not, what do you recommend?

Disclaimer: This is a clear solicitation by me for help with my PHP class. I will be teaching this class at my local college starting this semester. Please realize this is the first time my local college has considered PHP anything of importance.

In the past, the college has been totally ingrained in .NET (i.e., APS, VB, C#). They believe their focus should be teaching students what the Corporate World wants and those needs have been defined by the State of Michigan and General Motors. Considering that neither of those institutions are financially solvent, other avenues are being considered.

I know I can Google for "PHP tutorials", but I am looking for recommendations from this list as to which tutorials/references are the best.

Thanks,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
On Jan 16, 2011, at 1:26 PM, tedd wrote:

> Hi gang:
> 
> In the past we talked about PHP tutorials, but I don't remember if there was 
> a single clearinghouse/link for them or not -- is there one? If not, what do 
> you recommend?
> 
> Disclaimer: This is a clear solicitation by me for help with my PHP class. I 
> will be teaching this class at my local college starting this semester. 
> Please realize this is the first time my local college has considered PHP 
> anything of importance.
> 
> In the past, the college has been totally ingrained in .NET (i.e., APS, VB, 
> C#). They believe their focus should be teaching students what the Corporate 
> World wants and those needs have been defined by the State of Michigan and 
> General Motors. Considering that neither of those institutions are 
> financially solvent, other avenues are being considered.
> 
> I know I can Google for "PHP tutorials", but I am looking for recommendations 
> from this list as to which tutorials/references are the best.
> 
> Thanks,
> 
> tedd
> 
> -- 
> -------
> http://sperling.com/

I have always had good luck http://www.tizag.com/phpT/

I guess it would depend on what topics you want to cover. Do the students have 
prior programming experience? HTML / CSS / JavaScript (other frontend web stack 
language) experience? Do you want to do simple junk (submit form, view results) 
or more complex actions (database involvement, basic CMS, authentication 
systems)? 

Regards,

-Josh
____________________________________
Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com


--- End Message ---
--- Begin Message ---
On Sun, Jan 16, 2011 at 13:26, tedd <t...@sperling.com> wrote:
> Hi gang:
>
> In the past we talked about PHP tutorials, but I don't remember if there was
> a single clearinghouse/link for them or not -- is there one? If not, what do
> you recommend?

    While this isn't a direct response, it's an added idea: you might
want to see about a couple of guest speakers/presenters during the
semester.  Maybe some experts will be in the area who might be
interested in volunteering a few minutes out of their week to offer a
presentation (if the college allows it).

-- 
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--- End Message ---

Reply via email to