nzizo Posted May 31, 2008 Share Posted May 31, 2008 Hello, this is my send mail script with jpg attachment: <? $varsendmail = $_POST['varsendmail']; $vartext = $_POST['vartext']; $to = $varsendmail; $subject = 'subject'; $bound_text = "domain"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "ok \r\n" .$bound; $message .= "Content-Type: text/html; charset=\"utf-8\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" ."ok \r\n" .$bound; $file = file_get_contents("http://www.domain.com/images/image.jpg"); $message .= "Content-Type: image/jpg; name=\"image.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"image.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; if(mail($to, $subject, $message, $headers)) { echo "ok"; } else { die("error"); } ?> i want to send this mail to 5 more accounts (cc, bcc etc), please i need an example how to do it. thank you Quote Link to comment https://forums.phpfreaks.com/topic/108144-send-mail-to-5-more-accounts-i-need-info/ Share on other sites More sharing options...
jonsjava Posted May 31, 2008 Share Posted May 31, 2008 Send them through a loop (most likely a while loop). I'd give more help, but I have no idea what to code. are they fixed email addresses (the same ones every time), or do they change? Is it DB-driven? Quote Link to comment https://forums.phpfreaks.com/topic/108144-send-mail-to-5-more-accounts-i-need-info/#findComment-554326 Share on other sites More sharing options...
nzizo Posted May 31, 2008 Author Share Posted May 31, 2008 The values of variables coming by form, and need to send this mail to more accounts. So, I add the 5 more variables (emails from input fields), and my question is.. how to send the same email with the attachment also to them? <? $varsendmail = $_POST['varsendmail']; $vartext = $_POST['vartext']; $varemail1 = $_POST['varemail1']; $varemail2 = $_POST['varemail2']; $varemail3 = $_POST['varemail3']; $varemail4 = $_POST['varemail4']; $varemail5 = $_POST['varemail5']; $to = $varsendmail; $subject = 'subject'; $bound_text = "domain"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "ok \r\n" .$bound; $message .= "Content-Type: text/html; charset=\"utf-8\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" ."ok \r\n" .$bound; $file = file_get_contents("http://www.domain.com/images/image.jpg"); $message .= "Content-Type: image/jpg; name=\"image.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"image.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; if(mail($to, $subject, $message, $headers)) { echo "ok"; } else { die("error"); } ?> Thank you Quote Link to comment https://forums.phpfreaks.com/topic/108144-send-mail-to-5-more-accounts-i-need-info/#findComment-554365 Share on other sites More sharing options...
.josh Posted May 31, 2008 Share Posted May 31, 2008 $varsendmail = $_POST['varsendmail']; $vartext = $_POST['vartext']; $varemail1 = $_POST['varemail1']; $varemail2 = $_POST['varemail2']; $varemail3 = $_POST['varemail3']; $varemail4 = $_POST['varemail4']; $varemail5 = $_POST['varemail5']; $to = "$varsendmail, $varemail1, $varemail2, $varemail3, $varemail4, $varemail5"; Quote Link to comment https://forums.phpfreaks.com/topic/108144-send-mail-to-5-more-accounts-i-need-info/#findComment-554377 Share on other sites More sharing options...
nzizo Posted May 31, 2008 Author Share Posted May 31, 2008 Thank you, one more question.. if my variables is empty? this makes problem to script? Quote Link to comment https://forums.phpfreaks.com/topic/108144-send-mail-to-5-more-accounts-i-need-info/#findComment-554422 Share on other sites More sharing options...
.josh Posted May 31, 2008 Share Posted May 31, 2008 $varsendmail = $_POST['varsendmail']; $vartext = $_POST['vartext']; $varemail1 = $_POST['varemail1']; $varemail2 = $_POST['varemail2']; $varemail3 = $_POST['varemail3']; $varemail4 = $_POST['varemail4']; $varemail5 = $_POST['varemail5']; if ($varsendmail) { $to = "$varsendmail,"; } if ($varemail1) { $to .= "$varemail1,"; } if ($varemail2) { $to .= "$varemail2,"; } if ($varemail3) { $to .= "$varemail3,"; } if ($varemail4) { $to .= "$varemail4,"; } if ($varemail5) { $to .= "$varemail5,"; } rtrim($to,','); Quote Link to comment https://forums.phpfreaks.com/topic/108144-send-mail-to-5-more-accounts-i-need-info/#findComment-554434 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.