[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Сборка массива и отправка через phpmailer
DeeKeiD
Здравствуйте, подскажите как собрать и отправить массив через phpMailer?

Input'ы

<input type="text" name="name[]" placeholder="Name, Surname">
<input
type="text" name="phone[]" placeholder="Phone">
<input
type="text" name="amats[]" placeholder="Type">


phpMailer
Свернутый текст

//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server
$mail->Host = 'smtp.online.lv';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 465;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'ssl';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "pults22@evorm.lv";

//Password to use for SMTP authentication
$mail->Password = "pults22123";

//Set who the message is to be sent from
$mail->setFrom('info@evorm.lv', 'Evorm LTD Infolapa');

//Set an alternative reply-to address
//$mail->addReplyTo('replyto@example.com', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('pults22@evorm.lv', 'Evorm LTD');

//Set the subject line
$mail->Subject = $infotypesubject;

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));

//Replace the plain text body with one created manually
//$mail->AltBody = 'This is a plain-text message body';
$mail->Body = '

<table width="100%">
<tr>
<td
width="30%">Vards, Uzvards:</td>
<td
width="70%">'. $sender_name .'</td>
</tr>
<tr>
<td
width="30%">E-Pasts:</td>
<td
width="70%">'. $sender_email .'</td>
</tr>
<tr>
<td
width="30%">Objekta fiziskā adrese:</td>
<td
width="70%">'. $sender_object_address .'</td>
</tr>
<tr>
<td
width="30%">Objekta nosaukums(ja ir tāds):</td>
<td
width="70%">'. $sender_object_name .'</td>
</tr>
<tr>
<td
width="30%">Ieejas/kāpņutelpas kods:</td>
<td
width="70%">'. $sender_object_kt_kods .'</td>
</tr>
<tr>
<td
width="30%">Ieejai/kāpņu telpai ir atslēga:</td>
<td
width="70%">'. $sender_object_keys .'</td>
</tr>
<tr>
<td
width="30%">Atbildīgās personas:</td>
<td
width="70%">'. $sender_object_persons .'</td>
</tr>
<tr>
<td
width="30%">Piezīmes:</td>
<td
width="70%">'. $sender_message .'</td>
</tr>
</table>

';
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';

for($ct=0;$ct<count($_FILES['attach_file']['tmp_name']);$ct++){
$mail->AddAttachment($_FILES['attach_file']['tmp_name'][$ct],$_FILES['attach_file']['name'][$ct]);
}
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}


Пробовал через foreach, на выходе каша

foreach ($cname as $a_name){
echo $a_name;
foreach ($cphone as $a_phone){
echo $a_phone;
foreach($ctype as $a_type){
echo $a_type;
}
}
}

Как получить вывод в виде таблицы и впихнуть его в тело письма?:

| Name 1 | Phone 1 | Type 1 |
| Name 2 | Phone 2 | Type 2 |
| Name 3 | Phone 3 | Type 4 |


_____________
Бесполезно просить пощады у цезаря
Фатальная ошибка : Звонок в неопределенную функцию ©
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.