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


Groups > comp.lang.php > #14182

Re: sending pdf files to individual email...

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: sending pdf files to individual email...
Date 2014-08-19 11:42 -0400
Organization A noiseless patient Spider
Message-ID <lsvra3$ia9$1@dont-email.me> (permalink)
References <80518368-4133-4211-9d51-4949a5799d06@googlegroups.com> <65ddceac-4854-480c-8bb1-208bef6c2148@googlegroups.com>

Show all headers | View raw


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
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web