Jump to content

WireMailSmtp missing attached files extensions


mrkhan
 Share

Recommended Posts

Hello,

I am building one form to send email with WireMailSmtp

every thing is working fine, only thing attachments are sending with email without any extension.

what i want to do is
1. first check the attached file and only allow image/ pdf and word file to be attached

2. send email with attachment.
 

here is my code

if (isset($input->post->submit)) {

$form = array(
'name' => $input->post->name,
'email' => $input->post->email,
'message' => $input->post->message,
'email2' => $input->post->email2
);

$photo=$filetemp = $_FILES["photo"];
/// how to check that file is only image

$resume=$filetemp = $_FILES["resume"];
/// how to check the file is only PDF or word file

/// email12 is for spam boot
if($form[email2] =="")
{
$toName='my website';
$toEmail=$page->email;
$subject="CV EMail";
$textBody= "Full name: $form[name]\n" .
               "Email: $form[email]\n" .
			   "Message: $form[message]";

$mail = wireMail();
$mail->to($toEmail, $toName);
$mail->from = $toEmail; 
$mail->subject($subject);

$mail->attachment($photo);
$mail->attachment($resume);

$mail->body($textBody);

$numSent = $mail->send();
if($numSent)
{
  $output="Message Send";
}else{
  $output="Message Not Send";
}

}

}

 

 

Link to comment
Share on other sites

Hi,

first thing, if you have a question regarding a module, please use its support board thread!

One solution to determine / validate filetypes would be to check the magic bytes. Imagetypes that are supported by the native php function getimagesize can be detected by that function.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By Juergen
      Hello @ all
      I want to share a new module with you, which makes the creation and validation of forms easy.  Take a look at the following example of a simple contact form:
      // A very simple example of a contactform for demonstration purposes $form = new Form('contactform'); $gender = new Select('gender'); $gender->setLabel('Gender'); $gender->addOption('Mister', '0'); $gender->addOption('Miss', '1'); $form->add($gender); $surname = new InputText('surname'); $surname->setLabel('Surname'); $surname->setRule('required'); $form->add($surname); $name = new InputText('name'); $name->setLabel('Name'); $name->setRule('required'); $form->add($name); $email = new InputText('email'); $email->setLabel('E-Mail'); $email->setRule('required'); $form->add($email); $subject = new InputText('subject'); $subject->setLabel('Subject'); $subject->setRule('required'); $form->add($subject); $message = new Textarea('message'); $message->setLabel('Message'); $message->setRule('required'); $form->add($message); $privacy = new InputCheckbox('privacy'); $privacy->setLabel('I accept the privacy policy'); $privacy->setRule('required')->setCustomMessage('You have to accept our privacy policy'); $form->add($privacy); $button = new Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if($form->isValid()){ print_r($form->getValues()); // do what you want } // render the form echo $form->render(); This piece of code creates a simple contact form and validates it according to the validation rules set. Inside the isValid() method you can run your code (fe sending an email)
      Highlights:
      30+ validation types Support for UiKit 3 and Bootstrap 5 CSS framework SPAM protection Highly customizable Hookable methods for further customization Multi-language You can download and find really extensive information on how to use at https://github.com/juergenweb/FrontendForms.
      Please report errors or suggestions directly in GitHub.
      Best regards and happy testing 🙂
    • By fruid
      What's wrong with my code? It just won't send emails. It worked before when not using wiremailSMTP but now it stops. This is used in a contact form.
      It has to be the code because when I run a test in the module, it works fine and the email reaches me.
      Even the Promailer-Newsletters using WireMail SMTP work fine now.
      Even when I put some debug code on the template to be send to me via email with every email, that email reaches me. 
      But somehow the email in question, send with contact form does not.
      BTW if-condition works fine cause redirection works as well.
      Here's my code:
      if (isset($_POST['sendform']) && $captcha->verifyResponse() === true) :     $givenname = $input->post->text('givenname');      $familyname = $input->post->text('familyname');      $fullname = $givenname.' '.$familyname;     $fullname = ucwords($fullname);     $email = $input->post->email('emailaddress');      $subject = $input->post->text('subject');      $message = $input->post->text('message');      $m = wireMail();     $m->to('myemail@mydomain.com', 'my Name');     $m->from($email, $fullname);     $m->subject($subject);     $m->body($message);     $m->send();     $session->redirect($pages->get("/kontakt/danke/")->url); endif; I recently installed a SSL certificate on the webserver, but that should be irrelevant, right?
      Further settings:
      port: 587
      Allow Connection without Authentication: no
      SMTP User and SMTP Password provided
      Use Start-TLS: no
      TLS Crypto method: 1.2
      Use SSL: no
      Allow self signed certificated: no
      Thanks for help!
       
    • By benbyf
      Hi, Looking to create form elements on a page–some input with a colection of form inputs and the appropriate labels and variables for that input. I've used ProForms in the past and rolled out my own when creating simply one off forms, but I wonder if anyone has found a good way of allowing form creation on page editing so that clients can adhocly make and edit forms?
      Thanks
    • By Mithlesh
      Hi there,
      My form is not getting submitted, it is showing:
      Unable to verify successful email delivery of this form submission.
      Attaching for your reference as well: 

      In the Backend, it is showing Connection timed out with smtp.gmail.com
      Pl guide me how to resolve that
    • By abdulqayyum
      hello processwire community,
      i am using LoginRegister module for front-end user registration. i am facing an issue verification email not receiving while WireMailSmtp is working perfectly and user receives message
      "Thank you, a confirmation code has been emailed to you. When you receive the email, click the link it contains, or paste the confirmation code below."
      received this message in front-end but does not receive any email relevant it.
      please help me in this case how i can solve it.
      Please check screen shots for SMTP test and message which receives user.
      Thanks AbdulQayyum,

      First screenshot SMTP test message, second when user receives message after clicking register button.
×
×
  • Create New...