Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include the mailer
- require_once "phpmailer/class.phpmailer.php";
- $mail = new PHPMailer(true);
- $mail->IsSMTP();
- $mail->SMTPDebug = 2;
- $mail->SMTPAuth = true;
- $message = "Send email with <strong style='color: #ff0000'>PHPMailer</strong> from my SMTP account.<br />";
- try {
- // First we should get the file
- // This is the folder you should store the uploaded files in temporarily while they are being attached. "Keep it Secret, Keep it Safe."
- $target_path = "uploads/"
- $target_path = $target_path . basename($_FILES['kool_name_here']['name']);
- if ( move_uploaded_file($_FILES['kool_name_here']['tmp_name'], $target_path)) {
- // Attach A file!
- $mail->AddAttachment(basename($target_path . $_FILES['uploadedfile']['name']))
- }
- //SMTP server
- $mail->Host = "SMTP host";
- //SMTP port, for example, 25, 587, 2525, ...
- $mail->Port = 587;
- //SMTP account username
- $mail->Username = "youraccount@SMTP host";
- //SMTP account password
- $mail->Password = "yourpassword";
- //mail from
- $mail->SetFrom($mail->Username, "your name");
- //replay to
- $mail->AddReplyTo($mail->Username, "your name");
- $recipient_address = "recipient@somedomain.com";
- $recipient_name = "recipient name";
- $mail->AddAddress($recipient_address, $recipient_name);
- //adding carbon copy CC recipients
- //$mail->AddCC("recipient1@domain.com", "First Person");
- //adding blind carbon copy BCC recipients
- //$mailer->AddBCC("recipient1@domain.com", "First Person");
- $mail->Subject = "Test email sending";
- //create an alternate automatically
- //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
- // Attach the message as HTML. Remember HTML for emails is super lame and not standard.
- $mail->MsgHTML($message);
- $mail->Send();
- echo "<br />Message Sent OK!";
- } catch (phpmailerException $e)
- {
- echo $e->errorMessage();
- } catch (Exception $e)
- {
- echo $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement