Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('MAIL_HOST', 'mail.example.com');
- define('MAIL_PORT', 25);
- define('MAIL_USERNAME', 'mail@example.com');
- define('MAIL_PASSWORD', 'PasswordExample');
- define('MAIL_FROM_NAME', 'Example From Name');
- function phpmailer_mail_send($to, $mail_subject, $mail_body, $who = null, $cc = array(), $bcc = array()){
- $phpmailer = new PHPMailer();
- $phpmailer->SMTPAuth = true;
- $phpmailer->Username = MAIL_USERNAME;
- $phpmailer->Password = MAIL_PASSWORD;
- $phpmailer->isSMTP();
- $phpmailer->Host = MAIL_HOST;
- $phpmailer->CharSet = 'UTF-8';
- //begin: turn off SSL
- $phpmailer->SMTPSecure = false;
- $phpmailer->SMTPAutoTLS = false;
- //end: turn off SSL
- $phpmailer->Port = MAIL_PORT;
- $phpmailer->Sender = MAIL_USERNAME;
- if( isset($who) && filter_var($who, FILTER_VALIDATE_EMAIL) !== FALSE ){
- $phpmailer->AddReplyTo( $who );
- }
- $phpmailer->setFrom( MAIL_USERNAME, MAIL_FROM_NAME );
- $phpmailer->Subject = $mail_subject;
- $phpmailer->Body = $mail_body;
- $phpmailer->IsHTML(true);
- foreach($to as $email_to):
- $phpmailer->addAddress($email_to);
- endforeach;
- foreach($cc as $email_cc):
- $phpmailer->addCC($email_cc);
- endforeach;
- foreach($bcc as $email_bcc):
- $phpmailer->addBCC($email_bcc);
- endforeach;
- return $phpmailer->send();
- }//mail_send
- ?>
Add Comment
Please, Sign In to add comment