Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //now select all contacts for the company who receive all accounts emails
- $sql="SELECT * from contacts where company_sequence = '".$result2["sequence"]."' and receive_accountsemails = 'yes' ";
- $rs=mysql_query($sql,$conn) or die(mysql_error());
- if(mysql_num_rows($rs) > 0)
- {
- while($contacts2=mysql_fetch_array($rs))
- {
- //generate the list of emails address in an array
- $emails_list[] = $contacts2["email"];
- }
- $emails_list = implode(',',$emails_list);
- //this is some clever shit to do with sending emails with attachments
- $email = new PHPMailer();
- $email->From = 'no-reply@integradigital.co.uk';
- $email->FromName = 'Integra Digital';
- $email->Subject = 'Invoice ';
- $email->Body = $msgbody;
- $email->AddAddress($emails_list);
- $email->IsHTML(true);
- $email->AddAttachment( $attachment , basename($attachment) );
- $email->AddAttachment( $understand_your_invoice_attachment , basename($understand_your_invoice_attachment) );
- if(!$email->Send())
- {
- echo "Mailer Error: " . $email->ErrorInfo;
- }
- else
- {
- echo 'Email sent to:' . $emails_list . '<br/ >';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement