- Posts: 44
- Thank you received: 6
Ask the community, share ideas, and connect with other LimeSurvey users!
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require '../../application/third_party/phpmailer/src/Exception.php'; require '../../application/third_party/phpmailer/src/PHPMailer.php'; require '../../application/third_party/phpmailer/src/SMTP.php'; if ( 0 < $_FILES["data"]["error"] ) { echo 'Error: ' . $_FILES["data"]["error"] . '<br>'; } else { $a = get_defined_vars();unset($a['GLOBALS'], $a['_ENV'], $a['_SERVER']);print_r($a); // This is in the PHP file and sends a Javascript alert to the client $message = "uploaded file!"; $uid = sha1($_POST["drivemail"]); $fnamedir = "uploads/drive_".$uid.".pdf"; $fname = "drive_".$uid.".pdf"; echo "<script type='text/javascript'>alert('$message');</script>"; move_uploaded_file($_FILES["data"]["tmp_name"], $fnamedir); } //Create a new PHPMailer instance $mail = new PHPMailer(); $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail $mail->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = "some@somedomain.com"; $mail->Password = "something"; //Set who the message is to be sent from $mail->setFrom('some@somedomain.com', 'some'); //Set an alternative reply-to address $mail->addReplyTo('some@somedomain.com', 'some'); //Set who the message is to be sent to $mail->addAddress($_POST["drivemail"], some'); //Set the subject line $mail->Subject = 'Your DRIVE Survey Results'; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML(file_get_contents('hello.html'), __DIR__); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file $mail->addAttachment($fnamedir, $fname); //send the message, check for errors if (!$mail->send()) { echo 'Mailer Error: '. $mail->ErrorInfo; } else { unlink($fnamedir); echo 'Message sent!';
User completes the survey and provides their email address in order for us to email them the results as a pdf
That would mean users could make changes to the text using LS rather than editing a seperate html file.
+1You know that the email templates are stored in "lime_surveys_languagesettings".
You should be able to load them from your php program and use them.