Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

mail function - send out same email to multiple recipients

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mail function - send out same email to multiple recipients

Postby holy24 » Mon Oct 22, 2012 7:30 pm

Hi guys,

I have tried out the email function, but I only can send to 1 recipient, can someone advise me how to sent email to multiple recipients. Also how can I add "AddReply To" to multiple recipients in include_mail.php?Thanks.

The codes are as below:

include_mail.php

<?php

function mysendmail($to,$subject,$msg){ // set email format to HTML

require_once("class.phpmailer.php");
$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "xxx.xx.xx.xxx";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "xxxx@xxxx.com.sg"; // SMTP username
$mail->Password = "xxxxxx"; // SMTP password

$mail->From = "xxxxx@xxxxx.com.sg";
$mail->FromName = "xxxx";
$mail->AddReplyTo("xxxxx@xxxx.com.sg", "xxxxx");
$mail->WordWrap = 100; // set word wrap to 50 characters
$mail->IsHTML(true);


$mail->AddAddress($to);
//if(strlen($cc)>3){
// $mail->AddCC($cc);
//}else{}
$mail->Subject=$subject;
$mail->Body=$msg;
$mail->Send();

}
//echo "msg send $to $subject $msg";
?>

test.php
<?php
include "include_mail.php";
mysendmail('recipient's email','subject','message');
?>
holy24
New php-forum User
New php-forum User
 
Posts: 6
Joined: Mon Sep 03, 2012 7:28 pm

Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.