<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bilgisayar &#187; PHPMailer</title>
	<atom:link href="https://www.bilgisayar.me/index.php/tag/phpmailer/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bilgisayar.me</link>
	<description></description>
	<lastBuildDate>Wed, 29 Aug 2018 20:31:06 +0000</lastBuildDate>
	<language>tr-TR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.29</generator>
	<item>
		<title>Oluşturulan PDF belgesini E-posta ile gönderme</title>
		<link>https://www.bilgisayar.me/index.php/2015/06/30/olusturulan-pdf-belgesini-e-posta-ile-gonderme/</link>
		<comments>https://www.bilgisayar.me/index.php/2015/06/30/olusturulan-pdf-belgesini-e-posta-ile-gonderme/#comments</comments>
		<pubDate>Tue, 30 Jun 2015 20:40:35 +0000</pubDate>
		<dc:creator><![CDATA[Hakan Atılgan]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[e-posta]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHPMailer]]></category>
		<category><![CDATA[tcpdf]]></category>

		<guid isPermaLink="false">http://www.bilgisayar.me/?p=989</guid>
		<description><![CDATA[Eğer PDF belgesi nasıl oluşturulduğu hakkında bilgi sahibi değilseniz, &#8220;TCPDF ile PDF nasıl oluşturulur?&#8221; yazımı okumak için burayı tıklayın. Liste halinde ne yapacağımızı sıralarsak, aşağıdaki kod ile, İlk önce veritabanından bütün şehirleri çağıracağız Verileri&#46;&#46;&#46;]]></description>
				<content:encoded><![CDATA[<p>Eğer PDF belgesi nasıl oluşturulduğu hakkında bilgi sahibi değilseniz, &#8220;TCPDF ile PDF nasıl oluşturulur?&#8221; yazımı okumak için <a href="http://www.bilgisayar.me/index.php/2015/06/28/tcpdf-ile-pdf-olusturma/" target="_blank">burayı <i class="fa fa-external-link"></i></a> tıklayın.</p>
<p>Liste halinde ne yapacağımızı sıralarsak, aşağıdaki kod ile, </p>
<ul>
<li>İlk önce veritabanından bütün şehirleri çağıracağız</li>
<li>Verileri PDF belgesi olarak ornek_1.pdf dosyası adında temp klasörüne yükleyeceğiz</li>
<li>Son olarak, oluşturulan PDF belgesini e-postamıza iliştireceğiz</li>
</ul>
<pre class="prettyprint linenums" >
    $db_host = &quot;localhost&quot;; //Host address (most likely localhost)
    $db_name = &quot;veritabnı_ismi&quot;; //veritabani ismi
    $db_user = &quot;root&quot;; //veritabani kullanici ismi
    $db_pass = &quot;788888&quot;; //sifre
    $mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
    $mysqli-&gt;query(&quot;SET NAMES utf8&quot;);
     
    require_once(&#039;config/lang/eng.php&#039;);
    require_once(&#039;tcpdf.php&#039;);
     
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, &#039;UTF-8&#039;, false);
    $pdf-&gt;SetFont(&#039;dejavusans&#039;, &#039;&#039;, 14, &#039;&#039;, true);
    $pdf-&gt;AddPage();
     
    //
    $q = &#039;SELECT * FROM `iller` ORDER BY sehir ASC&#039;;
    $res = $mysqli-&gt;query($q);	
    $html=&#039;&#039;;
    while($nt=$res-&gt;fetch_array()){
        $html .= $nt[&#039;sehir&#039;].&#039;&lt;br&gt;&#039;;
    }
    //
     
    $pdf-&gt;writeHTML($html, true, false, true, false, &#039;L&#039;); 
    $pdf-&gt;Output(&#039;temp/ornek_1.pdf&#039;, &#039;F&#039;); // oluşturulan belge ismi - ornek_1.pdf
    /*
    I - PDF belgesini tarayıcıya satır içi gönder (tarayıcıda göster) 
    D - PDF belgesini yüklemek için uyar
    F - PDF belgesini yerel sunucuya yükle
    */
</pre>
<p>Yukarıda PDF belgesini oluşturduk ve temp klasörüne yükledik.</p>
<p>Oluşturduğumuz PDF belgesini e-postamıza iliştireceğiz.E-postamızı göndermek için PHPMailer PHP sınıfını kullanacağız. PHPMailer&#8217; i <a href="http://phpmailer.worxware.com/" target="_blank">buradan <i class="fa fa-external-link"></i></a> yükleyebilirsiniz.</p>
<pre class="prettyprint linenums" >
&lt;?PHP
require(&quot;PHPMailer/class.phpmailer.php&quot;);
$eposta = new PHPMailer();
$eposta-&gt;From      = &#039;isminiz@bilgisayar.me&#039;; //e-posta adresiniz
$eposta-&gt;FromName  = &#039;Isminiz&#039;; // Isminiz ve adresiniz
$eposta-&gt;Subject   = &#039;Mesaj Başlığı&#039;; 
$eposta-&gt;Body      = &#039;Mesajınız&#039;; //Mesajınız
$eposta-&gt;AddAddress( &#039;isim@bilgisayar.me&#039; ); // kime gidiyor

$dosya = &#039;temp/ornek_1.pdf&#039;; // 

$eposta-&gt;AddAttachment( $dosya , &#039;ornek_1.pdf&#039; );

if(!$eposta-&gt;Send()) {
  echo &quot;Hata Oluştu: &quot; . $eposta-&gt;ErrorInfo;
} else {
  echo &quot;Mesaj Gönerildi!&quot;;
}
?&gt;
</pre>
<p>Kodları birleştirelim.</p>
<pre class="prettyprint linenums" >
&lt;?PHP
$db_host = &quot;localhost&quot;; //Host address (most likely localhost)
$db_name = &quot;veritabnı_ismi&quot;; //veritabani ismi
$db_user = &quot;root&quot;; //veritabani kullanici ismi
$db_pass = &quot;788888&quot;; //sifre
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
$mysqli-&gt;query(&quot;SET NAMES utf8&quot;);
 
require_once(&#039;config/lang/eng.php&#039;);
require_once(&#039;tcpdf.php&#039;);
require_once(&quot;PHPMailer/class.phpmailer.php&quot;);
 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, &#039;UTF-8&#039;, false);
$pdf-&gt;SetFont(&#039;dejavusans&#039;, &#039;&#039;, 14, &#039;&#039;, true);
$pdf-&gt;AddPage();
 
//
$q = &#039;SELECT * FROM `iller` ORDER BY sehir ASC&#039;;
$res = $mysqli-&gt;query($q);	
$html=&#039;&#039;;
while($nt=$res-&gt;fetch_array()){
	$html .= $nt[&#039;sehir&#039;].&#039;&lt;br&gt;&#039;;
}
//
 
$pdf-&gt;writeHTML($html, true, false, true, false, &#039;L&#039;); 
$pdf-&gt;Output(&#039;temp/ornek_1.pdf&#039;, &#039;F&#039;); // oluşturulan belge ismi - ornek_1.pdf
/*
I - PDF belgesini tarayıcıya satır içi gönder (tarayıcıda göster) 
D - PDF belgesini yüklemek için uyar
F - PDF belgesini yerel sunucuya yükle
*/

$eposta = new PHPMailer();
$eposta-&gt;From      = &#039;isminiz@bilgisayar.me&#039;; //e-posta adresiniz
$eposta-&gt;FromName  = &#039;Isminiz&#039;; // Isminiz ve adresiniz
$eposta-&gt;Subject   = &#039;Mesaj Başlığı&#039;; 
$eposta-&gt;Body      = &#039;Mesajınız&#039;; //Mesajınız
$eposta-&gt;AddAddress( &#039;isim@bilgisayar.me&#039; ); // kime gidiyor

$dosya = &#039;temp/ornek_1.pdf&#039;; // 

$eposta-&gt;AddAttachment( $dosya , &#039;ornek_1.pdf&#039; );

if(!$eposta-&gt;Send()) {
  echo &quot;Hata Oluştu: &quot; . $eposta-&gt;ErrorInfo;
} else {
  echo &quot;Mesaj Gönerildi!&quot;;
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.bilgisayar.me/index.php/2015/06/30/olusturulan-pdf-belgesini-e-posta-ile-gonderme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
