Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function send_mail($mail_to, $thema, $html2, $path, $logo_name='logo.png',$contacts=0,$em='')
- {
- $val = MAILGUN;
- $val2 = CONTACTFORMMAILGUN;
- if ($val=='true' or ($contacts==1 and $val2=='TRUE')) {
- //$from='info@'.str_replace("www.","",$_SERVER['HTTP_HOST']);
- $from="contacts@pharmacomstore.net";
- $name = "Pharmacom Labs";
- $from= $name.'<'.$from.'>';
- if ($contacts==1 and !filter_var($em, FILTER_VALIDATE_EMAIL) === false) {
- $from= $em;
- }
- $html =
- '<html>'.
- '<head>'.
- '<title>'.$thema.'</title>'.
- '</head>'.
- '<body>'.
- '<style>a { color:#777; } .list-sender p{margin:0px !important;}</style>'.
- '<div style="margin:0; padding:10px; background-color:#F2F2F2;">'.
- '<div style="width:650px; margin:0 auto; margin-top:10px; padding:15px; margin-bottom:10px; background-color:#fff; border-bottom:2px solid #D8D6D1;">'.
- '<p style="text-align:left; border-bottom: 1px solid #D8D6D1; padding-bottom: 25px;">'.
- '<a href="http://'.$_SERVER['HTTP_HOST'].'"><img src="cid:'.$logo_name.'" style="max-height: 65px;"></a>'.
- '</p>'.
- '<p style="height:10px;"></p>'.
- $html2.
- '<p style="min-height:10px"></p>'.
- '</div>'.
- '<p style="font-family:\'Helvetica\',\'Arial\',sans-serif;color:#9ca1ae;font-size:12px;font-weight:300;text-align:center;margin-bottom:10px;">© '.date("Y").' <a href="http://'.$_SERVER['HTTP_HOST'].'" style="color:#777" target="_blank">'.$_SERVER['HTTP_HOST'].'</a></p>'.
- '</div>'.
- '</body>'.
- '</html>';
- //$html = str_replace("cid:","",$html);
- $mailgunmes =
- array(
- 'from' => $from,
- 'to' => $mail_to,
- 'subject' => $thema,
- 'html' => $html
- );
- $i = 0;
- foreach($path as $key=>$value) {
- $mailgunmes['inline['.$i.']'] = "@".$value;
- $i++;
- }
- $key='key-80158eb7ed7638cea435faa204bc660d';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_USERPWD, 'api:'.$key);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
- curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/pharmacomstore.net/messages');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $mailgunmes);
- $result = curl_exec($ch);
- curl_close($ch);
- } else {
- //$from='info@'.str_replace("www.","",$_SERVER['HTTP_HOST']);
- $from="contacts@pharmacomstore.net";
- $name = "Pharmacom Labs";
- $from= $name.'<'.$from.'>';
- if ($contacts==1 and !filter_var($em, FILTER_VALIDATE_EMAIL) === false) {
- $from= $em;
- }
- $html =
- '<html>'.
- '<head>'.
- '<title>'.$thema.'</title>'.
- '<style>a { color:#777;} p{margin:0px !important;}</style>'.
- '</head>'.
- '<body>'.
- '<div style="margin:0; padding:10px; background-color:#F2F2F2;">'.
- '<div style="width:650px; margin:0 auto; margin-top:10px; padding:15px; margin-bottom:10px; background-color:#fff; border-bottom:2px solid #D8D6D1;">'.
- '<p style="text-align:left; border-bottom: 1px solid #D8D6D1; padding-bottom: 25px;">'.
- '<a href="http://'.$_SERVER['HTTP_HOST'].'"><img src="cid:'.$logo_name.'" style="max-height: 65px;"></a>'.
- '</p>'.
- '<p style="height:10px;"></p>'.
- $html2.
- '<p style="min-height:10px"></p>'.
- '</div>'.
- '<p style="font-family:\'Helvetica\',\'Arial\',sans-serif;color:#9ca1ae;font-size:12px;font-weight:300;text-align:center;margin-bottom:10px;">© '.date("Y").' <a href="http://'.$_SERVER['HTTP_HOST'].'" style="color:#777" target="_blank">'.$_SERVER['HTTP_HOST'].'</a></p>'.
- '</div>'.
- '</body>'.
- '</html>';
- $html=fix_newlines($html);
- if (substr(strrchr($mail_to, "@"), 1)=='protonmail.ch' or substr(strrchr($mail_to, "@"), 1)=='protonmail.com') {
- $headers = "From: " . $from . "\r\n";
- $headers .= "Reply-To: ". $mail_to . "\r\n";
- //$headers .= "CC: ".$from."\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
- mail($mail_to, $thema, $html, $headers);
- } else {
- $EOL = "\n";
- $boundary = "--".(uniqid(time()));
- $headers = "MIME-Version: 1.0;$EOL";
- $headers .= "From: ".$from."$EOL";
- $headers .= "Content-Type: multipart/related; boundary=\"$boundary\"$EOL";
- $multipart = "--{$boundary}$EOL";
- $multipart .= "Content-Type: text/html; charset=utf-8$EOL";
- $multipart .= "Content-Transfer-Encoding: 8bit$EOL";
- $multipart .= $EOL;
- $multipart .= str_replace("\r\n", "\n", $html);
- $multipart .= $EOL;
- if (!empty($path))
- {
- for($i = 0; $i < count($path); $i++)
- {
- $file = file_get_contents($path[$i]);
- $name = basename($path[$i]);
- $multipart .= "$EOL--$boundary$EOL";
- $multipart .= "Content-Type: image/jpeg; name=\"$name\"$EOL";
- $multipart .= "Content-Transfer-Encoding: base64$EOL";
- $multipart .= "Content-ID: <".$name.">$EOL";
- $multipart .= $EOL;
- $multipart .= chunk_split(base64_encode($file), 76, $EOL);
- }
- }
- $multipart .= "$EOL--$boundary--$EOL";
- if(!mail($mail_to, $thema, $multipart, $headers)) { return false; } else { return true; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement