Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'Classes/mail/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $recipient = $_POST['email_address'];
- $recipient = preg_replace('/s+/', '', $recipient);
- $recipient = trim($recipient, ';');
- $recipient_array = explode(';', $recipient);
- $subject = $_POST['email_subject'];
- $body = nl2br($_POST['email_message']);
- $footer = '<br />
- <table id="email_footer">
- <tr>
- <td>
- EMAIL SIGNATURE
- </td>
- </tr>
- <tr>
- <td>
- <hr />
- FOOTER IMAGE
- <hr />
- </td>
- </tr>
- <tr>
- <td style="font-size:15px">
- ADDRESS
- </td>
- </tr>
- </table>';
- $attachment = 'pdf/' . $_POST['attachment'];
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'localhost'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'webmaster@example.com'; // SMTP username
- $mail->Password = 'password123'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = "25"; // TCP port to connect to
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- $mail->setFrom('webmaster@example.com', 'Business Name');
- $mail->addReplyTo('webmaster@example.com', 'Business Name');
- for ( $i = 0; $i < count( $recipient_array ); $i++ )
- {
- $mail->addAddress( $recipient_array[$i] );
- }
- $mail->addAddress('example@zoho.com'); // Forwards to local email for records (cannot send email to own server [workaround])
- $mail->Subject = $subject; // Subject
- $mail->Body = $body . '<br />' . $footer; // Body of email
- $mail->AddAttachment( $attachment, 'purchase-order.pdf' ); // Attach a file
- $mail->isHTML(true); // Set email format to HTML
- if( !$mail->send() )
- {
- echo 'Message could not be sent.<br />';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement