Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form type="submit" enctype="multipart/form-data">
- <input type="file" name="attachment">
- <button name="submit" type="submit">SEND</button>
- </form>
- if(isset($_POST['submit'])){
- extract($_POST);
- $to="example@email.com";
- $msg="email body";
- require 'include/PHPMailer_master/src/PHPMailer.php';
- require 'include/PHPMailer_master/src/SMTP.php';
- require 'include/PHPMailer_master/src/Exception.php';
- $mail = new PHPMailerPHPMailerPHPMailer(true);
- enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 2;
- $mail->isSMTP();
- $mail->Host = 'smtp.siteprotect.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'example@email.com';
- $mail->Password = 'password';
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- $mail->setFrom('example@email.com');
- $mail->addAddress($to);
- $mail->addAttachment($_FILES['attachment']['tmp_name'],
- $_FILES['attachment']['name'] );
- $mail->isHTML(true);
- $mail->Subject = 'RESUME - Sales Engineer (from website careers page)';
- $mail->Body = $msg;
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo '<script>alert("Message has been sent");</script>';
- } catch (Exception $e) {
- echo '<script>alert("Message not sent");</script>';
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement