php群發郵件

來源:互聯網
上載者:User

簡介:這是php群發郵件的詳細頁面,介紹了和php,有關的知識、技巧、經驗,和一些php源碼等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=325740' scrolling='no'>
發過郵件的人都知道,從別人那裡申請的郵箱,沒法群發。有些人說QQ不是群發嗎?對是可以,但只能一次性發30個以內!發多了QQ郵箱就發不出去了!再說也沒有法自訂郵箱格式!

下面說一下傳統群發郵件方法!你如果不會寫php程式你可以選擇用群發軟體!在這裡我們先只講php程式!如下:

mail.class.php地址:http://www.123lianjie.com/mail.class.txt

<?php

include("mail.class.php");

$scontent = date("Y-m-d H-i-s");

##########################################

$smtpserver = "smtp.tom.com";//SMTP伺服器

$smtpserverport =25;//SMTP伺服器連接埠

$smtpusermail = "c@tom.com";//SMTP伺服器的使用者郵箱

$smtpemailto = "e421083458@163.com";//發送給誰

$smtpuser = "c";//SMTP伺服器的使用者帳號

$smtppass = "3780292";//SMTP伺服器的使用者密碼

$mailsubject = "感恩2009,相約2010,導購泉城祝您元旦快樂";//郵件主題

$mailbody = $scontent;//郵件內容

$mailtype = "HTML";//郵件格式(HTML/TXT),TXT為文本郵件

##########################################

$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//這裡面的一個true是表示使用身分識別驗證,否則不使用身分識別驗證.

$smtp->debug = false;//是否顯示發送的調試資訊

$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);

?>

如果你用這種方法發的郵件過多!smtp伺服器就有可能把你暫時屏蔽!這時你就無法發出郵件了!怎麼避免這種問題呢?自己架勢mail伺服器就沒問題了!

在這裡我們的用WinWebMail 3.7.7.3來架設mail伺服器!建議把所有限制全部√去!這樣mail伺服器就能得最大限度的應用!

找出自己的多個網域名稱!分別做一個次層網域指向你的mail伺服器IP!然後再再你的mail伺服器上綁定上網域名稱!然後用以上多個網域名稱分別註冊多個帳號!這樣子你就不只是一個smtp伺服器了!是多個!adsl使用者IP綁定問題大家都會吧!用路由做一個映射!就可以了!測試伺服器是否能夠正常使用!

如果沒有問題了!我們就來寫php群發程式了!

我們要先想幾個問題!1.不要發郵件過快,10s可以吧!2.能按數組來發郵件這樣方便加的入郵箱列表!3.輪流使用不同的發信地址來發送郵件!具體大家看程式吧!

<?php

include("mail.class.php");

session_start();

$email_arr = explode("|","421083458@qq.com");

//print_r($email_arr);

if(!isset($_SESSION['e']))

$_SESSION['e'] = 0;

if($_SESSION['e']>=count($email_arr))

die("全部郵件發送完畢!");

$e = $_SESSION['e'];

$_SESSION['e'] = $_SESSION['e']+1 ;

echo $e;

date_default_timezone_set('PRC');

$scontent = date("Y-m-d H-i-s");

$domain = array(

     "0"=>array("0"=>"k@mail.kemeishuma.com","1"=>"k","2"=>"3780292"),

     "1"=>array("0"=>"p@mail.penghuaji.org","1"=>"p","2"=>"3780292"),

     "2"=>array("0"=>"s@mail.smileshoping.cn","1"=>"s","2"=>"3780292"),

     "3"=>array("0"=>"1@mail.123lianjie.com","1"=>"1","2"=>"3780292"),

     "4"=>array("0"=>"c@mail.chunshuiji.org","1"=>"c","2"=>"3780292"),

     );

if(!isset($_SESSION['i'])||$_SESSION['i']>4)

$_SESSION['i'] = 0;

$i = $_SESSION['i'];

$_SESSION['i'] = $_SESSION['i']+1 ;

##########################################

$smtpserver = "mail.chunshuiji.org";//SMTP伺服器

$smtpserverport =25;//SMTP伺服器連接埠

$smtpusermail = $domain[$i][0];//SMTP伺服器的使用者郵箱

$smtpemailto = $email_arr[$e];//發送給誰

$smtpuser = $domain[$i][1];//SMTP伺服器的使用者帳號

$smtppass = $domain[$i][2];//SMTP伺服器的使用者密碼

$mailsubject = "感恩2009,相約2010,導購泉城祝您元旦快樂";//郵件主題

$mailbody = $scontent;//郵件內容

$mailtype = "HTML";//郵件格式(HTML/TXT),TXT為文本郵件

##########################################

$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//這裡面的一個true是表示使用身分識別驗證,否則不使用身分識別驗證.

$smtp->debug = true;//是否顯示發送的調試資訊

$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);

?>

<script>

function gonext()

{

setTimeout("location.href='sentmail.php?id=<?php echo $email_arr[$e]?>'",10000);

}

</script>

使用者<?php echo $email_arr[$e]?>郵件發送成功!

<script>gonext()</script>

“php群發郵件”的更多相關文章 》

愛J2EE關注Java邁克爾傑克遜視頻站JSON線上工具

http://biancheng.dnbcw.info/php/325740.html pageNo:13

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.