Bulk send email

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
vintoICT
User
Posts: 372

Bulk send email

Post by vintoICT »

i was able to send email to single email . How do I send email to multiple email address looped from all email on database table ?


arbei
User
Posts: 8746

Post by arbei »

vintoICT wrote:

i was able to send email to single email . How do I send email to multiple email address looped from all email on database table ?

You may just get the emails from the table (e.g. by ExecuteRows()), loop through the records and put your working code (for single email) inside the loop.


vintoICT
User
Posts: 372

Post by vintoICT »

Thank you. How do i add attachments to the mail?

// Email Sending event
function Email_Sending($email, $args)
{
    $rsnew = $args["rsnew"];
                $surname=CurrentUserinfo("surname");
                $firstname=CurrentUserinfo("firstname");
                $othername=CurrentUserinfo("othername");
                $fullname="$surname $firstname ";
                $senderemail=CurrentUserinfo("email");
                    $msgto=$rsnew["msgto"];
                    $msg=$rsnew["message"];
                    $subjecttemp=$rsnew["subject"];
                    $subject= strtoupper($subjecttemp);
                  $state= $rsnew["state"];
              $location=$rsnew["location"];
              $priority=$rsnew["priority"];
              $alert=$rsnew["alerttype"];
              $details=$rsnew["details"];
             $sEmail_List = "".$senderemail.""; 
              $email->Recipient = $sEmail_List; // Change recipient to a field value in the new record
              $email->Subject=$subject;
                              $email->Content = '
                           
                              <p> <center>'.$subject.'</center></p>
   <p> 
   <p>From: '.$senderemail.'</p>
   <p>To: '.$msgto.'</p>
<p>Cc:</p>
   </p>
      <p>Dear Sir/Madam,</p>
    <p>
    This email was sent by <b>('.$fullname.')</b>from the <b>Company name</b>HR application please find the details below:<br>
    
    </p>
    <p>'.$msg.'</p>
    
    Best Regards,<br>
    Support
    </p>
           '; // start content from beginning here
                    return true;
}

my add page have file upload filed (multiple upload )


mobhar
User
Posts: 11473

Post by mobhar »

To send the attachment in your email, you may search for addAttachment keyword in this forum.


vintoICT
User
Posts: 372

Post by vintoICT »

I have been having issues using the loop.
this is my code

// Email Sending event
    public function emailSending($email, $args)
    {
     
      $allemail='';
      $sql = " SELECT *  FROM `staff` ";
      $stmt = ExecuteQuery($sql); // execute the query
            if ($stmt->rowCount() > 0) { // check condition: if record count is greater than 0
        while ($row = $stmt->fetch()) { // loop
            $allemail= $row["email"];
            $coma=',';
          $mail=  $allemail.=$coma;

          //  echo $mail;

        } }  // end loop

   // die;

        $rsnew = $args["rsnew"];
                    // $sAFileName = $this->attachment->attacment."/" . $Args["rsnew"]["attachment"] ;  
                               $surname=CurrentUserinfo("surname");
                               $firstname=CurrentUserinfo("firstname");
                               $othername=CurrentUserinfo("othername");
                               $fullname="$surname $firstname ";
                               $senderemail=CurrentUserinfo("email");
                                     $msg=$rsnew["message"];
                                   $subjecttemp=$rsnew["subject"];
                                   $subject= strtoupper($subjecttemp);
                            // $email->Sender = $senderemail;  
                            $sEmail_List = $mail; 
                             $email->Recipient = $sEmail_List; // Change recipient to a field value in the new record

$mail= $allemail.=$coma; is not getting the emails outside the loop .


arbei
User
Posts: 8746

Post by arbei »

You need to declare your $mail varable before the loop.


Post Reply