html - Blank email, no error when sending email with PHP -


my code not producing email , showing blank screen. have compared output other email , comparing headers seems no problem there.

code:

    function sendemail($pemail, $pfirst, $plast, $add1,$add2,$pcode) {      $messageplain="test here test ";     $messagehtml = "<p> test here </p>";     $myemail = "coconut@gmail.com";         //<-----put email address here. ----->     $test_email="blah@hotmail.co.uk";     $crlf = "\r\n";          echo "<br /><b>emailing ..." . $pemail. "</b><br />";          $to = $test_email;          //$to = "$first_name $lasyt_name<$pemail";         $email_subject = "with urgent regard pledge support speckled wood tq834112";         // add in our primary content boundary, , mime type specification - inline attachment image:         $sep = sha1(date('r', time()));         $headers = array         (     //        'content-transfer-encoding: 7bit',     //      'in-reply-to:'.$sep.'@speckledwood.org.uk',             'content-type: multipart/alternative; boundary="-php-'.$sep.'"',     //      'to: ' . $to,             'from: friends of speckled wood management trust <'.$myemail.'>',             'reply-to: friends of speckled wood management trust <'.$myemail.'>',             'mime-version: 1.0',     //        'date: ' . date('r', $_server['request_time']),             'message-id: <' . $_server['request_time'] . md5($_server['request_time']) . '@' . $_server['server_name'] . '>',             'x-mailer: php v' . phpversion(),     //      'return-path: friends of speckled wood management trust <'.$myemail.'>',     //        'x-originating-ip: ' . $_server['server_addr'],         );         $image="../assets/foswmt.jpg";         if(!file_exists($image)) die("error #000001: fatal error not locate email attachment image {$image}");         $attachment = file_get_contents($image);         $encoded = base64_encode($attachment);         $attached = chunk_split($encoded);          $email_body = array           (             '---php-'.$sep.'',             'content-type: multipart/alternative; boundary="-php-'.$sep.'"',             ' ',             ' ',             '---php-'.$sep.'',             'content type: text/plain; charset="iso-8859-2"',     //      'content-disposition: inline',             'content-transfer-encoding: quoted-printable',             ' ',             $messageplain,             ' ',             ' ',             '---php-'.$sep.'',             'content-type: text/html; charset="iso-8859-2"',     //      'content-disposition: inline',             'content-transfer-encoding: quoted-printable',             ' ',             '<html><body>',             '<p><centre><img src="cid:php-cid-'.$sep.'" alt="foswmt group" height="200" width="200"></centre></p>',             $messagehtml,             '</body></html>',             '---php-'.$sep.'--',             ' ',             '---php-'.$sep.'',             'content type: image/jpeg;',             'content-transfer-encoding: base64',             'contect-id: <php-cid-'.$sep.'>',             'content-disposition: attachment; filename = "logo.jpg"',             $attached,             '---php-'.$sep.'--'          );          $email_subject = $pfirst. " ". $plast . " wish make pledge urgent regard speckled wood tq834112";         // $headers .= "return-path: http://www.speckledwood.org.uk/donate\r\n";         $sent = mail($to,$email_subject,implode($crlf, $email_body),implode($crlf, $headers));          //echo( "<br /><br />header: <br />" . $headers."body: <br />". $email_body .  "<br /><br />");     }     ?>      <?php                 $count=0;                 $countemail=0;                  $conlivedata = mysql_pconnect("localhost","user","password");                     if (!$conlivedata) {                   echo "failed connect mysql: " . mysqli_connect_error();                 }                 $con = mysql_pconnect("instance41919.db.xeround.com:6326","user","password");                 if (!$con) {                   echo "failed connect mysql: " . mysqli_connect_error();                 }                 mysql_select_db("csv_db", $con)or die("a mysql error has occurred.your query: error: (" . mysql_errno() . ") " . mysql_error());                  $result = mysql_query("select * `tbl_name` emailaddr <> ' ' order `emailaddr`", $con) or die("<br/>a mysql query error has occurred.your query: error: (" . mysql_errno() . ") " . mysql_error());                  $total = (mysql_result($result, 0));                 ob_end_flush();                 $i=0;                  while($row = mysql_fetch_array($result)) {                     $email = $row['emailaddr'];                     $i++;                     if ($email != null ){                         mysql_select_db("foswood_db", $conlivedata) or die("<br/>a mysql error has occurred slecting database.<br />your query: <br/> error: (" . mysql_errno() . ") " . mysql_error());                         $liveresult = mysql_query("select count(*) pledges emailaddr = '$email'", $conlivedata) or die("<br/>a mysql error has occurred.<br />your query: <br /> error: (" . mysql_errno() . ") " . mysql_error());                         if(mysql_result($liveresult, 0) ) {                             $count +=1;                         } else {                             $countemail+= 1;                             echo $row['first_name'] . " " . $row['last_name'] . "       @ : " . $row['street_address']. "," . $row['street_address2']. "-" . $row['street_address']. "." . $row['postcode_address'];                             sendemail($row['emailaddr'],$row['first_name'],$row['last_name'] ,$row['street_address'],$row['street_address2'],$row['street_address'],$row['postcode_address']);                                      // calculate percentation                             $percent = intval(($i/$total) * 100)."%";                             // javascript updating progress bar , information                             echo '<script language="javascript">                             document.getelementbyid("progress").innerhtml="<div style=\"width:'.$percent.';background-color:#880000;\">&nbsp;</div>";                             document.getelementbyid("information").innerhtml="'.$i.' row(s) processed.";                             </script>';                              // buffer achieve minimum size in order flush data                             echo str_repeat(' ',1024*64);                              // send output browser                             flush();                            }                         mysql_select_db("csv_db", $con) or die("<br/>a mysql error has occurred slecting database.<br />your query: <br /> error: (" . mysql_errno() . ") " . mysql_error());                     }                     echo "<br />";                 }                 // tell user process completed                 echo '<script language="javascript">document.getelementbyid("information").innerhtml="process completed"</script>';                  echo "<br/><br/><b/>totals:  " .$countemail." users emailed . ". $count . " users have pledged.</b/>";                 mysql_close($con);                 mysql_close($conlivedata);      ?> 

email output:

    x-store-info:j++/jtczmobr++wnraa4pa4f5xd6uens1lp3ik0ye5aejpdieml+dlztxnwvfaro8tnno6obhga7l/djzgzox0ppu40fiobocmeufoon2lhkqez1hupwzd8509hwmnoi6c5vv2mwpthob2arsxfcxq==     authentication-results: hotmail.com; spf=none (sender ip 213.146.180.236) smtp.mailfrom=anonymous@plesk1.scl.co.uk; dkim=none header.d=gmail.com; x-hmca=none     x-sid-pra: blah@gmail.com     x-auth-result: none     x-sid-result: none     x-message-status: n:n     x-message-delivery: vj0xlje7dxm9mdtspte7yt0xo0q9mtthrd0xo1ndtd0w     x-message-info: aklyzgsc+lm8gd7dwuxysrnr5llybbvh97q7gldsvulibzntxamnodznstroicjdom3yfa8mqdhajb3blbvckgwyxogtqvpn3hhkvyihwpalwivoeaatyhiqodqbm88c293bzbrm/nmwfktrflu4qmmhyqubkcod     received: plesk1.scl.co.uk ([213.146.180.236]) bay0-mc3-f1.bay0.hotmail.com microsoft smtpsvc(6.0.3790.4900);          sun, 24 mar 2013 11:37:33 -0700     received: (qmail 8872 invoked uid 33); 24 mar 2013 18:37:32 +0000     date: 24 mar 2013 18:37:32 +0000     to: blah@hotmail.co.uk     subject: adam britton wish make pledge urgent regard speckled wood tq834112     x-php-originating-script: 10323:emailusers2.php     content-type: multipart/alternative; boundary="-php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191"     from: blah <blah@gmail.com>     reply-to: blah <blah@gmail.com>     mime-version: 1.0     message-id: <1364150249e01977f5edd650baa7b5e672a1d5bc96@www.speckledwood.org.uk>     x-mailer: php v5.3.2-1ubuntu4.10     return-path: anonymous@plesk1.scl.co.uk     x-originalarrivaltime: 24 mar 2013 18:37:33.0432 (utc) filetime=[a6013f80:01ce28be]      ---php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191     content-type: multipart/alternative; boundary="-php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191"       ---php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191     content type: text/plain; charset="iso-8859-2"     content-transfer-encoding: quoted-printable      test here test        ---php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191     content-type: text/html; charset="iso-8859-2"     content-transfer-encoding: quoted-printable      <html><body>     <p><centre><img src="cid:php-cid-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191" alt="foswmt group" height="200" width="200"></centre></p>     <p> test here </p>     </body></html>      ---php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191--     ---php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191     content type: image/jpeg;     content-transfer-encoding: base64     contect-id: <php-cid-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191>     content-disposition: attachment; filename = "logo.jpg"     /9j/4aaqskzjrgabageasabiaad/7ro4ughvdg9zag9widmumaa4qklna+0aaaaaabaasaaaaaea     agbiaaaaaqacoejjtqqnaaaaaaaeaaaahjhcsu0egqaaaaaabaaaab44qklna/maaaaaaakaaaaa     aaaaaaeaoejjtqqkaaaaaaabaaa4qklnjxaaaaaaaaoaaqaaaaaaaaacoejjtqp1aaaaaabiac9m     zgabagxmzgagaaaaaaabac9mzgabakgzmgagaaaaaaabadiaaaabafoaaaagaaaaaaabaduaaaab     ac0aaaagaaaaaaaboejjtqp4aaaaaabwaad/////////////////////////////a+gaaaaa////      etc...     ---php-12e6e3f21ec76200f42baff8c05e6cbbe0fbe191-- 

i can't tell problem code is, general advice using library swiftmailer instead. takes pain out of building multi-part , attachment e-mails.

other that, need first basic debugging: check program flow step step, output variable contents, until find reason why text ends blank. that'll give more specific question ask.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -