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

×
×
  • Create New...