Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //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
- 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
- $stmt = $db_con->prepare("SELECT * FROM tbl_sys");
- $stmt->execute();
- $sysRow = $stmt->fetch(PDO::FETCH_BOTH);
- $secure=$sysRow['secure'];
- $host=$sysRow['host'];
- $port=$sysRow['port'];
- $sys_email=$sysRow['sys_email'];
- $user_name=$sysRow['userName'];
- $password=$sysRow['password'];
- $sender=$sysRow['sender'];
- $replyTo=$sysRow['replyTo'];
- ?>
- //PHPMailer function the below settings are set according to the result set of the above piece of code
- <?php
- class CV{
- function send_mail($sys_email,$message,$subject){
- require_once('mailer/class.phpmailer.php');
- require_once('query.php');
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPDebug = 1;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = $secure;
- $mail->Host = $host;
- $mail->Port = $port;
- $mail->AddAddress($sys_email);
- $mail->Username=$user_name;
- $mail->Password=$password;
- $mail->SetFrom($sender);
- $mail->AddReplyTo($replyTo,"Prassi e Ricerca");
- $mail->addAttachment($targetPath);//this variable is defined in send mail file which is the below code
- $mail->Subject = $subject;
- $mail->MsgHTML($message);
- $mail->Send();
- }
- }
- ?>
- //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
- send the email
- //here I define the class that I've used in the above piece of code
- $sendCV = new CV();
- //the target path variable is where the file is stored on my server and what I need to send the attachment
- $targetPath = "../cv/ass_soc/".$applicantName." ".$applicantLastName.$_FILES['file']['name']; // Target path where file is to be stored
- //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
- $sendCV->send_mail($sys_email,$message,$subject);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement