Advertisement
Guest User

Untitled

a guest
Oct 7th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //now select all contacts for the company who receive all accounts emails
  2. $sql="SELECT * from contacts where company_sequence = '".$result2["sequence"]."' and receive_accountsemails = 'yes' ";
  3. $rs=mysql_query($sql,$conn) or die(mysql_error());
  4. if(mysql_num_rows($rs) > 0)
  5. {
  6. while($contacts2=mysql_fetch_array($rs))
  7. {
  8. //generate the list of emails address in an array
  9. $emails_list[] = $contacts2["email"];
  10. }
  11.  
  12. $emails_list = implode(',',$emails_list);
  13.  
  14. //this is some clever shit to do with sending emails with attachments
  15. $email = new PHPMailer();
  16. $email->From = 'no-reply@integradigital.co.uk';
  17. $email->FromName = 'Integra Digital';
  18. $email->Subject = 'Invoice ';
  19. $email->Body = $msgbody;
  20.  
  21. $email->AddAddress($emails_list);
  22. $email->IsHTML(true);
  23.  
  24. $email->AddAttachment( $attachment , basename($attachment) );
  25. $email->AddAttachment( $understand_your_invoice_attachment , basename($understand_your_invoice_attachment) );
  26.  
  27.  
  28. if(!$email->Send())
  29. {
  30. echo "Mailer Error: " . $email->ErrorInfo;
  31. }
  32. else
  33. {
  34. echo 'Email sent to:' . $emails_list . '<br/ >';
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement