Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14143 > unrolled thread

sending pdf files to individual email...

Started bynag <visitnag@gmail.com>
First post2014-07-28 22:31 -0700
Last post2014-08-22 22:46 -0700
Articles 14 — 9 participants

Back to article view | Back to comp.lang.php


Contents

  sending pdf files to individual email... nag <visitnag@gmail.com> - 2014-07-28 22:31 -0700
    Re: sending pdf files to individual email... "J.O. Aho" <user@example.net> - 2014-07-29 09:34 +0200
    Re: sending pdf files to individual email... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-29 11:40 +0100
      Re: sending pdf files to individual email... Jerry Stuckle <jstucklex@attglobal.net> - 2014-07-29 09:36 -0400
        Re: sending pdf files to individual email... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-29 18:31 +0100
          Re: sending pdf files to individual email... Jerry Stuckle <jstucklex@attglobal.net> - 2014-07-29 14:19 -0400
          Re: sending pdf files to individual email... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-07-29 20:40 +0200
            Re: sending pdf files to individual email... Luuk <luuk@invalid.lan> - 2014-07-30 20:26 +0200
          Re: sending pdf files to individual email... Denis McMahon <denismfmcmahon@gmail.com> - 2014-07-29 19:53 +0000
        Re: sending pdf files to individual email... Denis McMahon <denismfmcmahon@gmail.com> - 2014-07-29 19:50 +0000
    Re: sending pdf files to individual email... Derek Turner <frderek@cesmail.net> - 2014-07-29 11:11 +0000
    Re: sending pdf files to individual email... nag <visitnag@gmail.com> - 2014-08-19 07:20 -0700
      Re: sending pdf files to individual email... Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-19 11:42 -0400
      Re: sending pdf files to individual email... Michael Vilain <vilain@NOspamcop.net> - 2014-08-22 22:46 -0700

#14143 — sending pdf files to individual email...

Fromnag <visitnag@gmail.com>
Date2014-07-28 22:31 -0700
Subjectsending pdf files to individual email...
Message-ID<80518368-4133-4211-9d51-4949a5799d06@googlegroups.com>
Hi,

I have a basic idea on PHP and mysql.

I have a text file with employee_number and employee_name and employee_email id delimited with comma.

i have uploaded it into a mysql table called empDetails.

I have a folder containing pdf files. Each pdf file is named with <employee_number>.pdf 

Now I want to send the each pdf file to respective employee mail id as an attachment from my mail.

Kindly give me a solution.

Thanking you.

[toc] | [next] | [standalone]


#14144

From"J.O. Aho" <user@example.net>
Date2014-07-29 09:34 +0200
Message-ID<c3p14tFa7e0U1@mid.individual.net>
In reply to#14143
On 29/07/14 07:31, nag wrote:

Hi nag,

> I have a basic idea on PHP and mysql.
> I have a text file with employee_number and employee_name and employee_email id delimited with comma.
> i have uploaded it into a mysql table called empDetails.

I assume the table has three columns and not one column where you have a 
row from the csv.



> I have a folder containing pdf files. Each pdf file is named with <employee_number>.pdf
> Now I want to send the each pdf file to respective employee mail id as an attachment from my mail.

Look at www.php.net/manual/en/function.mail.php

Don't forget to verify that there is an pdf file to send before you try 
to send the mail, people do not like email which states there is an 
attachment and there is none or getting an empty email.


> Kindly give me a solution.

Do we get your salary too?


-- 

  //Aho

[toc] | [prev] | [next] | [standalone]


#14145

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-07-29 11:40 +0100
Message-ID<0.c785a44165ca78df9327.20140729114034BST.87ha2030ta.fsf@bsb.me.uk>
In reply to#14143
nag <visitnag@gmail.com> writes:
<snip>
> I have a text file with employee_number and employee_name and
> employee_email id delimited with comma.
>
> i have uploaded it into a mysql table called empDetails.

That may not be the best thing to do.  For example, if the definitive
source of the data is somewhere else and it's been exported to you to
do this task, putting it into a DB just complicates the process and adds
another point of failure.  It does not make the task any easier.

(Of course, there are lots of cases when it *is* the right thing to do --
it's impossible to say from what you've said.)

> I have a folder containing pdf files. Each pdf file is named with
> <employee_number>.pdf
>
> Now I want to send the each pdf file to respective employee mail id as
> an attachment from my mail.
>
> Kindly give me a solution.

There are two parts to this: constructing the emails and sending them.
You probably want something like the PEAR package Mail_Mime[1] for the
first part.  What the best way is to send the emails depends on many
factors.  The PEAR package Mail[2] is more flexible than PHP's built-in
mail function.  You might need it if, for example, you need to send the
mails using a specific mail system.

[1] http://pear.php.net/package/Mail_Mime
[1] http://pear.php.net/package/Mail

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#14147

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-07-29 09:36 -0400
Message-ID<lr881l$ovj$1@dont-email.me>
In reply to#14145
On 7/29/2014 6:40 AM, Ben Bacarisse wrote:
> nag <visitnag@gmail.com> writes:
> <snip>
>> I have a text file with employee_number and employee_name and
>> employee_email id delimited with comma.
>>
>> i have uploaded it into a mysql table called empDetails.
> 
> That may not be the best thing to do.  For example, if the definitive
> source of the data is somewhere else and it's been exported to you to
> do this task, putting it into a DB just complicates the process and adds
> another point of failure.  It does not make the task any easier.
> 
> (Of course, there are lots of cases when it *is* the right thing to do --
> it's impossible to say from what you've said.)
>

Actually, I think it's a pretty logical thing to do.  Retrieving data
from a SQL database is easier than a .csv file.

>> I have a folder containing pdf files. Each pdf file is named with
>> <employee_number>.pdf
>>
>> Now I want to send the each pdf file to respective employee mail id as
>> an attachment from my mail.
>>
>> Kindly give me a solution.
> 
> There are two parts to this: constructing the emails and sending them.
> You probably want something like the PEAR package Mail_Mime[1] for the
> first part.  What the best way is to send the emails depends on many
> factors.  The PEAR package Mail[2] is more flexible than PHP's built-in
> mail function.  You might need it if, for example, you need to send the
> mails using a specific mail system.
> 
> [1] http://pear.php.net/package/Mail_Mime
> [1] http://pear.php.net/package/Mail
> 

Pear's Mail package hasn't been updated in over 4 years and looks to
have been abandoned.  I find PHPMailer to be much superior.  It's
available on GitHub.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14149

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2014-07-29 18:31 +0100
Message-ID<0.cb7ec34f1f7a3ac6698c.20140729183132BST.87mwbscbrf.fsf@bsb.me.uk>
In reply to#14147
Jerry Stuckle <jstucklex@attglobal.net> writes:

> On 7/29/2014 6:40 AM, Ben Bacarisse wrote:
>> nag <visitnag@gmail.com> writes:
>> <snip>
>>> I have a text file with employee_number and employee_name and
>>> employee_email id delimited with comma.
>>>
>>> i have uploaded it into a mysql table called empDetails.
>> 
>> That may not be the best thing to do.  For example, if the definitive
>> source of the data is somewhere else and it's been exported to you to
>> do this task, putting it into a DB just complicates the process and adds
>> another point of failure.  It does not make the task any easier.
>> 
>> (Of course, there are lots of cases when it *is* the right thing to do --
>> it's impossible to say from what you've said.)
>
> Actually, I think it's a pretty logical thing to do.  Retrieving data
> from a SQL database is easier than a .csv file.

I'd say they are pretty much the same, with the DB being a tad more
fussy if it needs authentication.  But I was talking about the work
flow.  I was saying that fopen and an fgetcsv loop is easier than the
import *plus* the read from DB.

<snip>
>> [1] http://pear.php.net/package/Mail_Mime
>> [1] http://pear.php.net/package/Mail
>> 
>
> Pear's Mail package hasn't been updated in over 4 years and looks to
> have been abandoned.  I find PHPMailer to be much superior.  It's
> available on GitHub.

That looks very good.

I'd always assumed (without any justification) that it was the PHP
equivalent of CTAN for TeX or Hackage for Haskell -- that most of the
good stuff would eventually end up there (with some bad stuff that needs
to be filtered out).  Maybe PEAR is administered in some why that puts
people off, or maybe PHPMailer is a lone example?

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#14150

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-07-29 14:19 -0400
Message-ID<lr8ojm$kvs$1@dont-email.me>
In reply to#14149
On 7/29/2014 1:31 PM, Ben Bacarisse wrote:
> Jerry Stuckle <jstucklex@attglobal.net> writes:
> 
>> On 7/29/2014 6:40 AM, Ben Bacarisse wrote:
>>> nag <visitnag@gmail.com> writes:
>>> <snip>
>>>> I have a text file with employee_number and employee_name and
>>>> employee_email id delimited with comma.
>>>>
>>>> i have uploaded it into a mysql table called empDetails.
>>>
>>> That may not be the best thing to do.  For example, if the definitive
>>> source of the data is somewhere else and it's been exported to you to
>>> do this task, putting it into a DB just complicates the process and adds
>>> another point of failure.  It does not make the task any easier.
>>>
>>> (Of course, there are lots of cases when it *is* the right thing to do --
>>> it's impossible to say from what you've said.)
>>
>> Actually, I think it's a pretty logical thing to do.  Retrieving data
>> from a SQL database is easier than a .csv file.
> 
> I'd say they are pretty much the same, with the DB being a tad more
> fussy if it needs authentication.  But I was talking about the work
> flow.  I was saying that fopen and an fgetcsv loop is easier than the
> import *plus* the read from DB.
>

If all you're going to do is read sequentially from the file, then there
is no big difference.  But if you want to search the file, mark emails
as sent or any of a number of other things, then a sql database runs
rings around a .csv file.

> <snip>
>>> [1] http://pear.php.net/package/Mail_Mime
>>> [1] http://pear.php.net/package/Mail
>>>
>>
>> Pear's Mail package hasn't been updated in over 4 years and looks to
>> have been abandoned.  I find PHPMailer to be much superior.  It's
>> available on GitHub.
> 
> That looks very good.
> 
> I'd always assumed (without any justification) that it was the PHP
> equivalent of CTAN for TeX or Hackage for Haskell -- that most of the
> good stuff would eventually end up there (with some bad stuff that needs
> to be filtered out).  Maybe PEAR is administered in some why that puts
> people off, or maybe PHPMailer is a lone example?
> 

I don't know - I've never submitted anything to PEAR.  But there are a
number of packages available for PHP which aren't in PEAR.  PHPMailer is
just one of them.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14151

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-07-29 20:40 +0200
Message-ID<2322489.l0nUaAXmaq@PointedEars.de>
In reply to#14149
Ben Bacarisse wrote:

> Jerry Stuckle <jstucklex@attglobal.net> writes:
>> On 7/29/2014 6:40 AM, Ben Bacarisse wrote:
>>> nag <visitnag@gmail.com> writes:
>>> <snip>
>>>> I have a text file with employee_number and employee_name and
>>>> employee_email id delimited with comma.
>>>>
>>>> i have uploaded it into a mysql table called empDetails.
>>> 
>>> That may not be the best thing to do.  For example, if the definitive
>>> source of the data is somewhere else and it's been exported to you to
>>> do this task, putting it into a DB just complicates the process and adds
>>> another point of failure.  It does not make the task any easier.
>>> 
>>> (Of course, there are lots of cases when it *is* the right thing to do
>>> -- it's impossible to say from what you've said.)
>>
>> Actually, I think it's a pretty logical thing to do.  Retrieving data
>> from a SQL database is easier than a .csv file.
> 
> I'd say they are pretty much the same, with the DB being a tad more
> fussy if it needs authentication.  But I was talking about the work
> flow.  I was saying that fopen and an fgetcsv loop is easier than the
> import *plus* the read from DB.

You have to deal with several delimiters and escape sequences in a CSV, but 
not in a database.  A proper database does not have have empty lines/rows, 
which fgetcsv() cannot deal with properly (so you need a gauntlet there).
A good database format has character encoding information attached to the 
database, tables and columns, a CSV has not (which manifests itself strongly 
if you open UTF-8 CSVs in Excel from Windows Explorer). 
A database table column has a type; a CSV has only strings and you need to 
convert them.  It takes only one function/method call to slurp a whole 
database table into an associative array or an array of objects, several to 
do that with a CSV.
 
So I fail to see how CSVs could be easier to process with PHP than a 
database query result.  Parsing CSVs sometimes is a necessary evil (when 
people would not give you access to their database, or you cannot migrate 
directly), not something that should be made everyday practice.

> <snip>
>>> [1] http://pear.php.net/package/Mail_Mime
>>> [1] http://pear.php.net/package/Mail
>>
>> Pear's Mail package hasn't been updated in over 4 years and looks to
>> have been abandoned.

<https://github.com/pear/Mail> was last updated 4 _months_ ago.  However, if 
you cared to visit the site, you would have seen that Mail_Mime, which 
matters here, is much more actively developed: “1.8.9 (stable) was released 
on 2014-05-14”.  And then there is Mail2.

>> I find PHPMailer to be much superior.

I would not debate that at this time.

>> It's available on GitHub.

So are PEAR packages:

<http://blog.pear.php.net/2012/01/24/what-would-you-do-with-5-million-lines-of-code/>

> That looks very good.
> 
> I'd always assumed (without any justification) that it was the PHP
> equivalent of CTAN for TeX or Hackage for Haskell -- that most of the
> good stuff would eventually end up there (with some bad stuff that needs
> to be filtered out).  Maybe PEAR is administered in some why that puts
> people off, or maybe PHPMailer is a lone example?

They could do a much better job of pointing out that development is going on 
on GitHub now.  It is hard to find even a link to the PEAR git repository on 
pear.php.net.  And that double maintenance should cease, too.  Maybe it is 
an issue of manpower, misorganized personal resources?

-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#14154

FromLuuk <luuk@invalid.lan>
Date2014-07-30 20:26 +0200
Message-ID<j0qnab-053.ln1@luuk.invalid.lan>
In reply to#14151
On 29-7-2014 20:40, Thomas 'PointedEars' Lahn wrote:
> Ben Bacarisse wrote:
>
>> Jerry Stuckle <jstucklex@attglobal.net> writes:
>>> On 7/29/2014 6:40 AM, Ben Bacarisse wrote:
>>>> nag <visitnag@gmail.com> writes:
>>>> <snip>
>>>>> I have a text file with employee_number and employee_name and
>>>>> employee_email id delimited with comma.
>>>>>
>>>>> i have uploaded it into a mysql table called empDetails.
>>>>
>>>> That may not be the best thing to do.  For example, if the definitive
>>>> source of the data is somewhere else and it's been exported to you to
>>>> do this task, putting it into a DB just complicates the process and adds
>>>> another point of failure.  It does not make the task any easier.
>>>>
>>>> (Of course, there are lots of cases when it *is* the right thing to do
>>>> -- it's impossible to say from what you've said.)
>>>
>>> Actually, I think it's a pretty logical thing to do.  Retrieving data
>>> from a SQL database is easier than a .csv file.
>>
>> I'd say they are pretty much the same, with the DB being a tad more
>> fussy if it needs authentication.  But I was talking about the work
>> flow.  I was saying that fopen and an fgetcsv loop is easier than the
>> import *plus* the read from DB.
>
> You have to deal with several delimiters and escape sequences in a CSV, but
> not in a database.  A proper database does not have have empty lines/rows,

But when importing that csv file to your database you also have to solve 
these things......

[toc] | [prev] | [next] | [standalone]


#14153

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-07-29 19:53 +0000
Message-ID<lr8u39$p8d$2@dont-email.me>
In reply to#14149
On Tue, 29 Jul 2014 18:31:32 +0100, Ben Bacarisse wrote:

> Jerry Stuckle <jstucklex@attglobal.net> writes:

>> I find PHPMailer to be much superior.

> That looks very good.

Definite +1 for PHPMailer.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#14152

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-07-29 19:50 +0000
Message-ID<lr8ttv$p8d$1@dont-email.me>
In reply to#14147
On Tue, 29 Jul 2014 09:36:52 -0400, Jerry Stuckle wrote:

> Actually, I think it's a pretty logical thing to do.  Retrieving data
> from a SQL database is easier than a .csv file.

True, but given a file of empno & email as csv, and a directory of 
empno.pdf, it's probably as easy to step through the file, find the pdf, 
mail it as it is to read the file into a database, step through the file 
list and find the email from the db, email the file.

The directory of pdf files is effectively already random access data.

Swings and roundabouts, but if this was a once off event and I had no 
expectation of other uses for the empno / name / email table, I'm not 
sure I'd bother building a db for this mailshot.

The bigger question for me would be whether to use python or php to 
script the process. ;)

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#14146

FromDerek Turner <frderek@cesmail.net>
Date2014-07-29 11:11 +0000
Message-ID<c3pdq7Fcqk4U1@mid.individual.net>
In reply to#14143
On Mon, 28 Jul 2014 22:31:23 -0700, nag wrote:

> Hi,
> 
> I have a basic idea on PHP and mysql.

> Kindly give me a solution.
> 
> Thanking you.

Have a look at Zendmail for the mailing part. The PHP is trivial.

[toc] | [prev] | [next] | [standalone]


#14181

Fromnag <visitnag@gmail.com>
Date2014-08-19 07:20 -0700
Message-ID<65ddceac-4854-480c-8bb1-208bef6c2148@googlegroups.com>
In reply to#14143
On Tuesday, 29 July 2014 11:01:23 UTC+5:30, nag  wrote:
> Hi,
> 
> 
> 
> I have a basic idea on PHP and mysql.
> 
> 
> 
> I have a text file with employee_number and employee_name and employee_email id delimited with comma.
> 
> 
> 
> i have uploaded it into a mysql table called empDetails.
> 
> 
> 
> I have a folder containing pdf files. Each pdf file is named with <employee_number>.pdf 
> 
> 
> 
> Now I want to send the each pdf file to respective employee mail id as an attachment from my mail.
> 
> 
> 
> Kindly give me a solution.
> 
> 
> 
> Thanking you.


By going through the solutions given by the beloved friends, finally i could get one solution which is mentioned below. But the problem is I could only send one mail at a time to recipient mentioned in the php script. How can I send automatically to the list recipients explained as below:

Rather than creating a mySQl table I have one modified csv file and a folder containing pdf files to be sent to the recipients listed in csv file.

1. The csv file with empname, emp_number, emp_email_id
2. The folder containing the individual employee's pdf file named as <em_number>.pdf

The programmes I am using :

Netbeans IDE 8.0 in UBUNTU 14.04 OS at home
(RHEL 5.9 at work place without Netbeans)

The problems I am facing are:

The below mentioned programme is not running in RHEL 5.9 without Netbeans IDE.
There I am trying to run it in the browser directly.

I could send one file at a time not all simultaneously in the folder and listed 
in csv file.

How can I send with a single click to all the recipients mentioned in the csv
file and send attachment in the folder.


(the required class.phpmail.php is placed in the php mailer programme directory)


The Php mailer prog is :


<h1>
<?php
require('class.phpmailer.php');

$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
/*
//For TLS
$mail->SMTPSecure="tls";
$mail->Port=587;
*/
//For SSL
$mail->SMTPSecure="ssl";  
$mail->Port=465;  
$mail->Username="*****@gmail.com";
$mail->Password = "*********";
$mail->Host= "smtp.gmail.com";
$mail->Mailer= "smtp";
$mail->SetFrom("*******@gmail.com","My Mail");

$mail->AddAddress("*******@gmail.com");
$mail->Subject= "Test email using PHP mailer";
$mail->AddAttachment("<emp_number>.pdf");
$mail->WordWrap=70;
$content = "<b>This is a test email using PHP mailer class.</b>"; 
$mail->MsgHTML($content);
$mail->IsHTML(true);
if(!$mail->Send()) 
echo "Problem sending email.";
else 
echo "email sent.";
?>


Do I need Netbeans 8.0 to run the php script? Because in my work place. I am working on RHEL 5.9 without supporting Netbeans IDE.

Thank you.

[toc] | [prev] | [next] | [standalone]


#14182

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-08-19 11:42 -0400
Message-ID<lsvra3$ia9$1@dont-email.me>
In reply to#14181
On 8/19/2014 10:20 AM, nag wrote:
> On Tuesday, 29 July 2014 11:01:23 UTC+5:30, nag  wrote:
>> Hi,
>>
>>
>>
>> I have a basic idea on PHP and mysql.
>>
>>
>>
>> I have a text file with employee_number and employee_name and employee_email id delimited with comma.
>>
>>
>>
>> i have uploaded it into a mysql table called empDetails.
>>
>>
>>
>> I have a folder containing pdf files. Each pdf file is named with <employee_number>.pdf 
>>
>>
>>
>> Now I want to send the each pdf file to respective employee mail id as an attachment from my mail.
>>
>>
>>
>> Kindly give me a solution.
>>
>>
>>
>> Thanking you.
> 
> 
> By going through the solutions given by the beloved friends, finally i could get one solution which is mentioned below. But the problem is I could only send one mail at a time to recipient mentioned in the php script. How can I send automatically to the list recipients explained as below:
> 
> Rather than creating a mySQl table I have one modified csv file and a folder containing pdf files to be sent to the recipients listed in csv file.
> 
> 1. The csv file with empname, emp_number, emp_email_id
> 2. The folder containing the individual employee's pdf file named as <em_number>.pdf
> 
> The programmes I am using :
> 
> Netbeans IDE 8.0 in UBUNTU 14.04 OS at home
> (RHEL 5.9 at work place without Netbeans)
> 
> The problems I am facing are:
> 
> The below mentioned programme is not running in RHEL 5.9 without Netbeans IDE.
> There I am trying to run it in the browser directly.
> 
> I could send one file at a time not all simultaneously in the folder and listed 
> in csv file.
> 
> How can I send with a single click to all the recipients mentioned in the csv
> file and send attachment in the folder.
> 
> 
> (the required class.phpmail.php is placed in the php mailer programme directory)
> 
> 
> The Php mailer prog is :
> 
> 
> <h1>
> <?php
> require('class.phpmailer.php');
> 
> $mail=new PHPMailer();
> $mail->IsSMTP();
> $mail->SMTPDebug = 0;
> $mail->SMTPAuth = TRUE;
> /*
> //For TLS
> $mail->SMTPSecure="tls";
> $mail->Port=587;
> */
> //For SSL
> $mail->SMTPSecure="ssl";  
> $mail->Port=465;  
> $mail->Username="*****@gmail.com";
> $mail->Password = "*********";
> $mail->Host= "smtp.gmail.com";
> $mail->Mailer= "smtp";
> $mail->SetFrom("*******@gmail.com","My Mail");
> 
> $mail->AddAddress("*******@gmail.com");
> $mail->Subject= "Test email using PHP mailer";
> $mail->AddAttachment("<emp_number>.pdf");
> $mail->WordWrap=70;
> $content = "<b>This is a test email using PHP mailer class.</b>"; 
> $mail->MsgHTML($content);
> $mail->IsHTML(true);
> if(!$mail->Send()) 
> echo "Problem sending email.";
> else 
> echo "email sent.";
> ?>
> 
> 
> Do I need Netbeans 8.0 to run the php script? Because in my work place. I am working on RHEL 5.9 without supporting Netbeans IDE.
> 
> Thank you.
> 

You shouldn't need netbeans to run this script.  Why do you think you
need it?

As for sending to multiple people with one click - I'm assuming you need
to send a different attachment to each person.  So what you will need is
to loop through the code, using the appropriate address and attachment
to each email.

However, if you're sending several emails (the exact number depends on
your server configuration), you may run into timeout problems as the
script may run longer than is allowed.

The solution I use is to store all of the information in a SQL database
and have a cron job run every 15 minutes which checks the database for
any outstanding requests.  If it finds any, it sends the email then
marks the message as "sent" in the database.  It processes up to 10
requests at a time, then starts itself over again.

You still have to be a bit careful in that if the cron job takes longer
than 15 minutes to send the current list, another cron job may start
processing the same list.  I haven't had this problem (which is why I
use 15 minutes - typically it takes less than a minute for the small
list I have to send).

And if there are no messages to be sent, the cron job takes minimal
resources.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14191

FromMichael Vilain <vilain@NOspamcop.net>
Date2014-08-22 22:46 -0700
Message-ID<vilain-E6205C.22460022082014@news.individual.net>
In reply to#14181
In article <65ddceac-4854-480c-8bb1-208bef6c2148@googlegroups.com>,
 nag <visitnag@gmail.com> wrote:

> On Tuesday, 29 July 2014 11:01:23 UTC+5:30, nag  wrote:
> > Hi,
> > 
> > 
> > 
> > I have a basic idea on PHP and mysql.
> > 
> > 
> > 
> > I have a text file with employee_number and employee_name and 
> > employee_email id delimited with comma.
> > 
> > 
> > 
> > i have uploaded it into a mysql table called empDetails.
> > 
> > 
> > 
> > I have a folder containing pdf files. Each pdf file is named with 
> > <employee_number>.pdf 
> > 
> > 
> > 
> > Now I want to send the each pdf file to respective employee mail id as an 
> > attachment from my mail.
> > 
> > 
> > 
> > Kindly give me a solution.
> > 
> > 
> > 
> > Thanking you.
> 
> 
> By going through the solutions given by the beloved friends, finally i could 
> get one solution which is mentioned below. But the problem is I could only 
> send one mail at a time to recipient mentioned in the php script. How can I 
> send automatically to the list recipients explained as below:
> 
> Rather than creating a mySQl table I have one modified csv file and a folder 
> containing pdf files to be sent to the recipients listed in csv file.
> 
> 1. The csv file with empname, emp_number, emp_email_id
> 2. The folder containing the individual employee's pdf file named as 
> <em_number>.pdf
> 
> The programmes I am using :
> 
> Netbeans IDE 8.0 in UBUNTU 14.04 OS at home
> (RHEL 5.9 at work place without Netbeans)
> 
> The problems I am facing are:
> 
> The below mentioned programme is not running in RHEL 5.9 without Netbeans 
> IDE.
> There I am trying to run it in the browser directly.
> 
> I could send one file at a time not all simultaneously in the folder and 
> listed 
> in csv file.
> 
> How can I send with a single click to all the recipients mentioned in the csv
> file and send attachment in the folder.
> 
> 
> (the required class.phpmail.php is placed in the php mailer programme 
> directory)
> 
> 
> The Php mailer prog is :
> 
> 
> <h1>
> <?php
> require('class.phpmailer.php');
> 
> $mail=new PHPMailer();
> $mail->IsSMTP();
> $mail->SMTPDebug = 0;
> $mail->SMTPAuth = TRUE;
> /*
> //For TLS
> $mail->SMTPSecure="tls";
> $mail->Port=587;
> */
> //For SSL
> $mail->SMTPSecure="ssl";  
> $mail->Port=465;  
> $mail->Username="*****@gmail.com";
> $mail->Password = "*********";
> $mail->Host= "smtp.gmail.com";
> $mail->Mailer= "smtp";
> $mail->SetFrom("*******@gmail.com","My Mail");
> 
> $mail->AddAddress("*******@gmail.com");
> $mail->Subject= "Test email using PHP mailer";
> $mail->AddAttachment("<emp_number>.pdf");
> $mail->WordWrap=70;
> $content = "<b>This is a test email using PHP mailer class.</b>"; 
> $mail->MsgHTML($content);
> $mail->IsHTML(true);
> if(!$mail->Send()) 
> echo "Problem sending email.";
> else 
> echo "email sent.";
> ?>
> 
> 
> Do I need Netbeans 8.0 to run the php script? Because in my work place. I am 
> working on RHEL 5.9 without supporting Netbeans IDE.
> 
> Thank you.

Email doesn't work that way.  When you send email, you send to multiple 
recipients all in the header or one at a time with a loop.  A common 
SPAMMER practice is to send to "undisclosed recipients" and have all the 
actual addresses in the Bcc: header.  But that's the interface to 
mail--one message at a time and there's no way to send groups of people 
unless you include them all in the headers, either in "To:", "Cc:" or 
"Bcc:"

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web