Jump to content

Recommended Posts

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

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

$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";

 

$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,',');

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.