GithubHelp home page GithubHelp logo

bachors / php-sending-emails-to-multiple-recipients Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 7.0 6 KB

PHP sending emails to multiple recipients.

Home Page: http://ibacor.com/labs/php-sending-emails-to-multiple-recipients

License: MIT License

HTML 64.00% PHP 36.00%

php-sending-emails-to-multiple-recipients's Introduction

PHP-sending-emails-to-multiple-recipients

PHP sending emails to multiple recipients with AJAX (client side).

Sample PHP sending email:

# message header
$headers = "From: " . $_POST['to'] . "\r\n";
if(!empty($_POST['cc'])){
    $headers .= "CC: " . $_POST['cc'] . "\r\n";
}
if(!empty($_POST['bcc'])){
    $headers .= "BCC: " . $_POST['bcc'] . "\r\n";
}
if($_POST['type'] == 'html') {
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
}

send message

if(mail($_POST['to'], $_POST['subject'], $_POST['compose'], $headers)) { $result['status'] = 'success'; } else { $result['status'] = 'error'; }

# config SMTP
$config['protocol']     = 'smtp';
$config['smtp_host']     = 'mail.host.com';
$config['smtp_port']     = 123;
$config['smtp_crypto']    = 'tls';
$config['smtp_user']     = '[email protected]';
$config['smtp_pass']     = 'xxxxxxx';
if($_POST['type'] == 'html'){
    $config['mailtype']     = 'html';
    $config['charset']         = 'iso-8859-1';
}
$this->load->library('email', $config);

message header

$this->email->from('[email protected]', 'iBacor'); $this->email->to($_POST['to']); if(!empty($_POST['cc'])){ $this->email->cc($_POST['cc']); } if(!empty($_POST['bcc'])){ $this->email->bcc($_POST['bcc']); } $this->email->subject($_POST['subject']); $this->email->message($_POST['compose']); if($_POST['type'] == 'html'){ $this->email->set_mailtype("html"); }

send message

if($this->email->send()) { $result['status'] = 'success'; } else { $result['status'] = 'error'; }

# config SMTP
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); 
$mail->Host = 'smtp1.example.com;smtp2.example.com';
$mail->SMTPAuth = true;         
$mail->Username = '[email protected]';  
$mail->Password = 'secret';         
$mail->SMTPSecure = 'tls';      
$mail->Port = 587;           

message header

$mail->setFrom('[email protected]', 'iBacor'); $mail->addReplyTo($_POST['to']); if(!empty($_POST['cc'])){ $mail->addCC($_POST['cc']); } if(!empty($_POST['bcc'])){ $mail->addBCC($_POST['bcc']); } if($_POST['type'] == 'html'){ $mail->isHTML(true);
} $mail->Subject = $_POST['subject']; if($_POST['type'] == 'html'){ $mail->Body = $_POST['compose']; }else{ $mail->AltBody = $_POST['compose']; }

send message

if(!$mail->send()) { $result['status'] = 'success'; } else { $result['status'] = 'error'; }

This form builth with:

- bootstrap - fontawesome - select2 - tinymce

php-sending-emails-to-multiple-recipients's People

Contributors

bachors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.