Quote from: TobyL at May 06, 2009, 11:10 AM
Bridging eForm and WebLoginPE just so yu can send an email sounds a bit convoluted in my opinion and it’s certainly more work than adding a mailer to WebLoginPE. The mailer class is already there and if you look through the eForm.inc.php source there’s plenty of code you can copy.
You could write a plugin that’s triggered by WebLoginPE which captures your form data and sends the email. I don;t know WLPE vey well so you’ll have to figure out how it works with plugins (or perhaps someone else can help you with that).
As for working with phpMailer... here some sample code to get your started.
<?php
include_once "manager/includes/controls/class.phpmailer.php";
$mail_body = "Make your own message here. For instance use WLPE posted data....";
$mail_subject = "Someone registered on your site!";
$mail = new PHPMailer();
$mail->IsMail();
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML(1);
$mail->From = '[email protected]';
$mail->FromName = 'Your Name';
$mail->Subject = $mail_subject;
$mail->Body = $mail_body;//build this from your form data...
$mail->AddAddress('[email protected]');
//add attachment...
$attachment = $_FILES['replace_with_upload_form_field_name']['tmp_name'];
$contentType = $_FILES['replace_with_upload_form_field_name']['type'];
if (is_uploaded_file($attachment)){
$mail->AddAttachment($attachment,$FileName,"base64",$contentType);
}
$mail->send(); //ignoring any mailing errors
?>
I have included it in webloginpe.class.php
$Notify = new PHPMailer();
$Notify->CharSet = $modx->config['modx_charset'];
foreach ($emailArray as $address)
{
$Notify->From = $email;
$Notify->FromName = $fullname;
$Notify->Subject = $notifySubject;
$Notify->Body = $notification;
$Notify->AddAddress($address);
////////
$attachment = $_FILES['uploaded_file']['tmp_name'];
$contentType = $_FILES['uploaded_file']['type'];
if (is_uploaded_file($attachment)){
$Notify->AddAttachment($attachment,$FileName,"base64",$contentType);
}
////////
if (!$Notify->Send())
{
return $this->FormatMessage($Notify->ErrorInfo);
}
$Notify->ClearAddresses();
}
}
$this->SessionHandler('destroy');
$this->FormatMessage($this->LanguageArray[100].$modx->config['site_name']);
return 'success';
}
And it works, Thanks!
EDIT:
Is it possible to set the size limit of uploaded files size, to avoid spammers or somebody uploading a 50mb file
Edski