Advertisement
Guest User

Untitled

a guest
May 28th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. <?php
  2. //this is the first file where I make a select query to get some settings to use in PHPMailer function in another file which now is the code below
  3. require_once ('dbconfig.php');//this is the db connection file the one I fail to include and as a consequence the whole mail thing fails
  4. $stmt = $db_con->prepare("SELECT * FROM tbl_sys");
  5. $stmt->execute();
  6. $sysRow = $stmt->fetch(PDO::FETCH_BOTH);
  7. $secure=$sysRow['secure'];
  8. $host=$sysRow['host'];
  9. $port=$sysRow['port'];
  10. $sys_email=$sysRow['sys_email'];
  11. $user_name=$sysRow['userName'];
  12. $password=$sysRow['password'];
  13. $sender=$sysRow['sender'];
  14. $replyTo=$sysRow['replyTo'];
  15. ?>
  16. //PHPMailer function the below settings are set according to the result set of the above piece of code
  17. <?php
  18. class CV{
  19. function send_mail($sys_email,$message,$subject){
  20. require_once('mailer/class.phpmailer.php');
  21. require_once('query.php');
  22. $mail = new PHPMailer();
  23. $mail->IsSMTP();
  24. $mail->SMTPDebug = 1;
  25. $mail->SMTPAuth = true;
  26. $mail->SMTPSecure = $secure;
  27. $mail->Host = $host;
  28. $mail->Port = $port;
  29. $mail->AddAddress($sys_email);
  30. $mail->Username=$user_name;
  31. $mail->Password=$password;
  32. $mail->SetFrom($sender);
  33. $mail->AddReplyTo($replyTo,"Prassi e Ricerca");
  34. $mail->addAttachment($targetPath);//this variable is defined in send mail file which is the below code
  35. $mail->Subject = $subject;
  36. $mail->MsgHTML($message);
  37. $mail->Send();
  38. }
  39. }
  40. ?>
  41. //send mail is the last file where I store the file to a folder on my server, save its relative path to my db and then
  42. send the email
  43. //here I define the class that I've used in the above piece of code
  44. $sendCV = new CV();
  45. //the target path variable is where the file is stored on my server and what I need to send the attachment
  46. $targetPath = "../cv/ass_soc/".$applicantName." ".$applicantLastName.$_FILES['file']['name']; // Target path where file is to be stored
  47. //this is where I try to send the email I omitted the variables inside the send mail function because it's irrelevant for the actual problem
  48. $sendCV->send_mail($sys_email,$message,$subject);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement