Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <?php
  2.  
  3. function send_email($data) {
  4. require_once('../classes/class.phpmailer.php');
  5. $mail = new PHPMailer;
  6. //config
  7. $mail->isSMTP(); // Set mailer to use SMTP
  8. $mail->Host = MAIL_HOST; // Specify main and backup server
  9. $mail->SMTPAuth = true; // Enable SMTP authentication
  10. $mail->Username = MAIL_USERNAME; // SMTP username
  11. $mail->Password = MAIL_PASSWORD; // SMTP password
  12. //$mail->SMTPSecure = 'tls';
  13. //checking for the type of email to send
  14. // -------------- modifica doar aici ------------------
  15. $mail->Subject = $data['subject'];
  16.  
  17. global $EMAILS_BCC;
  18. $mail->From = MAIL_FROM;
  19. $mail->FromName = MAIL_FROM_NAME; //'Mailer';
  20. $mail->addAddress($data["to"], $data["to_name"]); //'josh@example.net', 'Josh Adams'); // Add a recipient
  21. $mail->addReplyTo(MAIL_FROM_NAME);
  22.  
  23. if (is_string($EMAILS_BCC)){
  24. $mail->addBCC($EMAILS_BCC);
  25. }
  26. else{
  27. foreach ($EMAILS_BCC as $em)
  28. if (is_array($em))
  29. $mail->addBCC($em['email'], $em['nume']);
  30. else
  31. $mail->addBCC($em);
  32. }
  33.  
  34. $mail->WordWrap = MAIL_WORDWRAP; // Set word wrap
  35. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  36. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  37. $mail->isHTML(true); // Set email format to HTML
  38.  
  39. $mail->Body = $data['message'];
  40. $mail->AltBody = strip_tags($data['message']);
  41.  
  42. if (!$mail->send()) {
  43. echo 'Mesajul nu a putut fi trimis.';
  44. echo 'Mailer Error: ' . $mail->ErrorInfo;
  45. return false;
  46. } else {
  47. return true;
  48. }
  49. }
  50.  
  51.  
  52.  
  53. $data = array('subject' => 'Mesaj nou Client',
  54. 'to' => isset($_POST['email']) ? $_POST['email'] : NULL,
  55. 'to_name' => isset($_POST['name']) ? $_POST['name'] : NULL,
  56. 'message' => isset($_POST['message']) ? $_POST['message'] : NULL);
  57.  
  58. send_email($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement