Blame view
sendEmailRequestEstimate.php
6.28 KB
670b6d6f8
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
<?php function array_to_csv_string($array, $filename = "3dHouse.csv", $delimiter=",") { //header('Content-Type: application/csv'); //header('Content-Disposition: attachment; filename="'.$filename.'";'); // open the "output" stream // see http://www.php.net/manual/en/wrappers.php.php#refsect2-wrappers.php-unknown-unknown-unknown-descriptioq //$f = fopen('php://output', 'w'); // Open temp file pointer if (!$f = fopen('php://temp', 'w+')) return FALSE; foreach ($array as $line) { fputcsv($f, explode(',',$line)); } // Place stream pointer at beginning rewind($f); // Return the data return stream_get_contents($f); } if( $_POST ){ $adminEmail = 'kitayama@main.co.jp'; $fullname = $_POST['txtName']; $email = $_POST['txtEmail']; $location = $_POST['optLocate']; $phone = $_POST['txtMobile']; $address = $_POST['txtAddress']; $requestDate = $_POST['txtRequestDate']; $note = $_POST['txtNote']; // $data = json_decode($_POST['data'], true); $data = $_POST['csv-data']; $arrayData = explode('|',$data); $csvAttachString = array_to_csv_string($arrayData, "3dHouse.csv"); // $htmlInfo = '<table class="table table-striped" border="0"> // <tr> // <td colspan="2"> // <div class="alert alert-info"> // <strong>Success</strong>, Your request have been send Successfully... // </div> // </td> // </tr>'; // //Full Name // $htmlInfo .= '<tr><td>氏名</td><td>'; // $htmlInfo .= $fullname; // $htmlInfo .= '</td></tr>'; // //Email // $htmlInfo .= '<tr><td>メールアドレス</td><td>'; // $htmlInfo .= $email; // $htmlInfo .= '</td></tr>'; // // Location // $htmlInfo .= '<tr><td>配送先</td><td>'; // $htmlInfo .= $location; // $htmlInfo .= '</td></tr>'; // // Phone // $htmlInfo .= '<tr><td>電話番号</td><td>'; // $htmlInfo .= $phone; // $htmlInfo .= '</td></tr>'; // // address // $htmlInfo .= '<tr><td>住所</td><td>'; // $htmlInfo .= $address; // $htmlInfo .= '</td></tr>'; // // request date // $htmlInfo .= '<tr><td>希望納期</td><td>'; // $htmlInfo .= $requestDate; // $htmlInfo .= '</td></tr>'; // // note // $htmlInfo .= '<tr><td>質問事項</td><td>'; // $htmlInfo .= $note; // $htmlInfo .= '</td></tr>'; // $htmlInfo .= '</table>'; $htmlInfo = ''; $htmlInfo .= '<p>【氏名】<br>'; $htmlInfo .= $fullname; $htmlInfo .= '</p>'; $htmlInfo .= '<p>【メールアドレス】<br>'; $htmlInfo .= $email; $htmlInfo .= '</p>'; $htmlInfo .= '<p>【配送先】<br>'; $htmlInfo .= $location; $htmlInfo .= '</p>'; $htmlInfo .= '<p>【電話番号】<br>'; $htmlInfo .= $phone; $htmlInfo .= '</p>'; $htmlInfo .= '<p>【住所】<br>'; $htmlInfo .= $address; $htmlInfo .= '</p>'; $htmlInfo .= '<p>【希望納期】<br>'; $htmlInfo .= $requestDate; $htmlInfo .= '</p>'; $htmlInfo .= '<p>【質問事項】<br>'; $htmlInfo .= $note; $htmlInfo .= '</p>'; $htmlMailContent =''; // Build HTML mail $htmlMailContent .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>3Dシミュレータからのお問合わせ</title> </head> <body> <div style="width: 640px; font-family: ms-gothic, sans-serif; font-size: 11px;"> <h3>ホームページの3Dシミュレータから、正式見積の依頼がありました。</h3> <h4>以下、お客様の情報です。</h4>'; $htmlMailContent .= $htmlInfo; $htmlMailContent .= '</div></body></html>'; // Prepare to send email require 'PHPMailer/PHPMailerAutoload.php'; //SMTP time zone set date_default_timezone_set('Etc/UTC'); /// ///Send mail by using gmail smtp /// //Create a new PHPMailer instance $mail = new PHPMailer; // To load the French version $mail->setLanguage('ja', 'PHPMailer/language/phpmailer.lang-ja.php'); //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.gmail.com'; // 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 = 587; //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail->Username = "naitce@gmail.com"; //Password to use for SMTP authentication $mail->Password = "Xinchaocacban"; //Set who the message is to be sent from $mail->setFrom('noreply@timesfun.net', '3Dシミュレー'); //Set an alternative reply-to address //$mail->addReplyTo('replyto@example.com', 'First Last'); //Set who the message is to be sent to $mail->addAddress($adminEmail, 'Admin'); $mail->isHTML(true); //Set the subject line $mail->Subject = '3Dシミュレータからのお問合わせ'; //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($htmlMailContent); //Replace the plain text body with one created manually $mail->AltBody = 'ホームページの3Dシミュレータから、正式見積の依頼がありました。'; $mail->CharSet="UTF-8"; //Attach an image file $mail->AddStringAttachment($csvAttachString, '3dHouse.csv', 'base64', 'application/csv'); // Make the attachment //$attachment = chunk_split(base64_encode(create_csv_string($csvData))); //$mail->addAttachment($output,'application/pdf','3DHouse-Estimation.pdf', false); //$mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo $htmlInfo; } } ?> |