PhpMail.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. date_default_timezone_set('Europe/Paris');
  3. require_once('class.phpmailer.php');
  4. class PhpMail
  5. {
  6. function PhpMail()
  7. {
  8. }
  9. public static function sendMail( $to, $subject, $message, $attachment = null)
  10. {
  11. $mail = new PHPMailer();
  12. $mail->IsSMTP(); // telling the class to use SMTP
  13. $mail->Host = "localhost"; // SMTP server
  14. //$mail->Debug = 1;
  15. // 1 = errors and messages
  16. // 2 = messages only
  17. $mail->SMTPAuth = false; // enable SMTP authentication
  18. $mail->Port = 25; // set the SMTP port for the GMAIL server
  19. $mail->SetFrom("support@intimamedia.com", "Intimamedia support");
  20. $mail->AddReplyTo("support@intimamedia.com", "Intimamedia support");
  21. $mail->Subject = $subject;
  22. $mail->MsgHTML($message);
  23. $address = $to;
  24. $mail->AddAddress($address, "");
  25. if ($attachment)
  26. $mail->AddAttachment($attachment); // attachment
  27. if(!$mail->Send())
  28. {
  29. $ff = fopen("mailError.log", "a+");
  30. fprintf($ff, "Mailer Error: %s\n", $mail->ErrorInfo);
  31. fclose($ff);
  32. return false;
  33. }
  34. return true;
  35. }
  36. }
  37. ?>