<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="lt">
	<id>https://wiki.eofnet.lt/w//index.php?action=history&amp;feed=atom&amp;title=Mail_siuntimo_sistema</id>
	<title>Mail siuntimo sistema - Versijų istorija</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.eofnet.lt/w//index.php?action=history&amp;feed=atom&amp;title=Mail_siuntimo_sistema"/>
	<link rel="alternate" type="text/html" href="https://wiki.eofnet.lt/w//index.php?title=Mail_siuntimo_sistema&amp;action=history"/>
	<updated>2026-04-15T19:09:13Z</updated>
	<subtitle>Šio puslapio versijų istorija projekte</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.eofnet.lt/w//index.php?title=Mail_siuntimo_sistema&amp;diff=8497&amp;oldid=prev</id>
		<title>\dev\null: straipsnis apie masinį el. laiškų siuntimą.</title>
		<link rel="alternate" type="text/html" href="https://wiki.eofnet.lt/w//index.php?title=Mail_siuntimo_sistema&amp;diff=8497&amp;oldid=prev"/>
		<updated>2017-10-04T11:09:31Z</updated>

		<summary type="html">&lt;p&gt;straipsnis apie masinį el. laiškų siuntimą.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Naujas puslapis&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Šis straipsnis apie masinį el. laiškų siuntimą bei scriptai skirti tiktai pažintiniams ir edukaciniams tikslams. Mes neatsakome už kitokį (blogą ar gerą) straipsnio panaudojimą.&lt;br /&gt;
&lt;br /&gt;
Reikalavimai sistemai:&lt;br /&gt;
* [[MySQL]] 5.x&lt;br /&gt;
* [[PHP]] 5.x&lt;br /&gt;
* [[PHP]] moduliai, '''pear install Mail Mail_Mime'''&lt;br /&gt;
* Sistemos prieiga su shell bash palaikymu&lt;br /&gt;
* Veikianti [[smtp]] serverio prieiga (tinka bet koks ISP paštas)&lt;br /&gt;
&lt;br /&gt;
MySQL duombazės lentelės struktūra:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
CREATE TABLE IF NOT EXISTS mailai (&lt;br /&gt;
  id INT(11) NOT NULL AUTO_INCREMENT,&lt;br /&gt;
  mail TEXT DEFAULT NULL,&lt;br /&gt;
  status VARCHAR(200) DEFAULT NULL,&lt;br /&gt;
  country VARCHAR(2) DEFAULT NULL,&lt;br /&gt;
  PRIMARY KEY (id)&lt;br /&gt;
) ENGINE=InnoDB&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
El. Pašto adresams naudojamas šis scriptas, kuris paima iš dokumento '''adresai.txt''', eile surašytus adresus ir importuoja į MySQL lentelę.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
inputfile=&amp;quot;adresai.txt&amp;quot;&lt;br /&gt;
country='lt';&lt;br /&gt;
cat $inputfile | while read mails; do&lt;br /&gt;
    echo &amp;quot;INSERT INTO mailai (mail, country) VALUES ('$mails','$country');&amp;quot;&lt;br /&gt;
done | mysql mailas;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Žemiau esantis scriptas skirtas siūsti el. laiškus, gavėjams iš duombazės lentelės.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php &lt;br /&gt;
//error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);&lt;br /&gt;
set_include_path(&amp;quot;.&amp;quot; . PATH_SEPARATOR . ($UserDir = dirname($_SERVER['DOCUMENT_ROOT'])) . &amp;quot;/pear/php&amp;quot; . PATH_SEPARATOR . get_include_path());&lt;br /&gt;
require_once &amp;quot;Mail.php&amp;quot;;&lt;br /&gt;
require_once &amp;quot;config.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$query = &amp;quot;select id, mail, status from mailai where country = 'lt'&amp;quot;;&lt;br /&gt;
$result = mysql_query($query, $con);&lt;br /&gt;
$emails = array();&lt;br /&gt;
while($row=mysql_fetch_assoc($result))&lt;br /&gt;
{&lt;br /&gt;
    $emails[]=$row['mail'];&lt;br /&gt;
}&lt;br /&gt;
$count =  file_get_contents(&amp;quot;count.txt&amp;quot;);&lt;br /&gt;
for($i=$count;$i&amp;lt;count($emails);$i++)&lt;br /&gt;
{&lt;br /&gt;
    $to  = $emails[$i];&lt;br /&gt;
    $message = file_get_contents(&amp;quot;mailas.html&amp;quot;); // this will get the HTML sample template sample.html&lt;br /&gt;
    $headers = array ('From' =&amp;gt; $from, 'To' =&amp;gt; $to, 'Subject' =&amp;gt; $subject, 'MIME-Version' =&amp;gt; 1, 'Content-type' =&amp;gt; 'text/html;charset=UTF-8', 'Reply-To' =&amp;gt; $from);&lt;br /&gt;
    $smtp = Mail::factory('smtp', array ('host' =&amp;gt; $host, 'port' =&amp;gt; '25', 'auth' =&amp;gt; true, 'username' =&amp;gt; $username, 'password' =&amp;gt; $password));&lt;br /&gt;
    $mail = $smtp-&amp;gt;send($to, $headers, $message);&lt;br /&gt;
 if (PEAR::isError($mail)) {&lt;br /&gt;
        $file = fopen(&amp;quot;notmailsentlist.txt&amp;quot;,&amp;quot;a+&amp;quot;);&lt;br /&gt;
        fwrite($file, $to.&amp;quot;,\r\n&amp;quot;);&lt;br /&gt;
        fclose($file);&lt;br /&gt;
} else { &lt;br /&gt;
        $file = fopen(&amp;quot;mailsentlist.txt&amp;quot;,&amp;quot;a+&amp;quot;);&lt;br /&gt;
        fwrite($file, $to.&amp;quot;,\r\n&amp;quot;);&lt;br /&gt;
        fclose($file);&lt;br /&gt;
    }&lt;br /&gt;
    if(($i-$count)&amp;gt;=100) // this will send 100 mails from database per execution&lt;br /&gt;
    {   &lt;br /&gt;
        $filec = fopen(&amp;quot;count.txt&amp;quot;,'w'); // store current count to count.txt&lt;br /&gt;
        fwrite($filec, $i);&lt;br /&gt;
        fclose($filec);&lt;br /&gt;
        break;&lt;br /&gt;
    }&lt;br /&gt;
}//for end&lt;br /&gt;
$filec = fopen(&amp;quot;count.txt&amp;quot;,'w'); // store fine count to count.txt this will be used as a start point of next execution&lt;br /&gt;
fwrite($filec, $i);&lt;br /&gt;
fclose($filec);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Pastarajį scriptą reikią užmauti ant crontab, kad pasileistų kas 5-10min. Scriptas savo statusą bei išsiųstų laiškų kiekį išsaugo, naujai paleistas pratesia darbą.&lt;br /&gt;
Taip pat susikurkite '''mailas.html''' failą kuriame parašysite norimo siųsti laiško turinį. Nepamirškite pakoreguoti apačioje esančio nustatymų failo '''config.php'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$con = mysql_connect(&amp;quot;localhost&amp;quot;,&amp;quot;root&amp;quot;,&amp;quot;passwordas&amp;quot;); // replace dbuser, dbpass with your db user and password&lt;br /&gt;
mysql_select_db(&amp;quot;mailas&amp;quot;, $con); // replace dbname with your database name&lt;br /&gt;
// smtp mailo setupas&lt;br /&gt;
$host = &amp;quot;mail.000.lt&amp;quot;;&lt;br /&gt;
$username = &amp;quot;000@000.lt&amp;quot;;&lt;br /&gt;
$password = &amp;quot;000&amp;quot;;&lt;br /&gt;
$subject = 'I just noticed you on Facebook group'; // Kokia laiško tema&lt;br /&gt;
$from = &amp;quot;000@000.lt&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
= Scrapinam mailus =&lt;br /&gt;
Mailams išgauti naudojami įvairūs triukai ir t.t. Čia aprašytas keletas.&lt;br /&gt;
&lt;br /&gt;
== Adresų išgavimas iš svetainės ==&lt;br /&gt;
 wget -q -r -l 5 -O - www.adresas.lt | grep -E -o &amp;quot;\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b&amp;quot;&lt;br /&gt;
== Išgavimas iš teksto ar kito materialo ==&lt;br /&gt;
 grep -E -o &amp;quot;\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b&amp;quot; materialas.txt | sort | uniq &amp;gt; pasto_adresai.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Mail]]&lt;br /&gt;
[[Category:Scripts]]&lt;/div&gt;</summary>
		<author><name>\dev\null</name></author>
	</entry>
</feed>