mailer.php 884 B

123456789101112131415161718192021222324252627
  1. <?php
  2. // Sends emails from the corporate website to the recipient
  3. function smtpmailer($to, $subject, $body, $attachment) {
  4. include('config.php');
  5. require_once('phpmailer/PHPMailerAutoload.php');
  6. $mail = new PHPMailer(); // create a new object
  7. $mail->IsSMTP(); // enable SMTP
  8. $mail->IsHTML(true);
  9. $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
  10. $mail->SMTPAuth = true; // authentication enabled
  11. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
  12. $mail->Host = 'smtp.gmail.com';
  13. $mail->Port = 465;
  14. $mail->Username = $mail_user;
  15. $mail->Password = $mail_password;
  16. $mail->SetFrom($mail_user, $mail_from_name);
  17. $mail->Subject = $subject;
  18. $mail->Body = $body;
  19. $mail->AddAddress($to);
  20. if ($attachment != null) {
  21. $mail->AddAttachment($attachment);
  22. }
  23. $mail->send();
  24. }
  25. ?>