導航:首頁 > 編程語言 > php搭建郵件伺服器

php搭建郵件伺服器

發布時間:2022-07-20 16:41:03

❶ 如何建立網站郵箱

隨便去一些大的門戶網站,如SINA;SOHU;163;YAHOO==看注冊郵箱,輸入你的信息就OK了

❷ 用php連續發送1萬封郵件,用mailer類行嗎用自己搭的郵箱伺服器

。具體步驟如下:
1.在伺服器安裝 sendmail
sudo apt-get install sendmail

2.啟動 sendmail
sudo /etc/init.d/sendmail start

3.修改 php.ini
[mail function]
SMTP = localhost
smtp_port = 25
sendmail_from = me@e

❸ php 發送郵件 要怎麼配置

在Windows平台下使用mail函數發送郵件,記錄如下

php.ini的設置:

SMTP = localhost
smtp_port = 25
sendmail_from=你的設定值

另外,還需要安裝IIS自帶的SMTP,在SMTP虛擬伺服器上點擊右鍵,在彈出的屬性窗口裡進行如下設置:
點擊訪問選項卡,再點擊中繼,在彈出的窗口出點擊添加,然後選單台計算機,添加IP地址為 127.0.0.1。然後一路確定返回。(不進行此項設置,可能會出現:SMTP server response: 550 5.7.1 Unable to relay for [email protected]。。。的錯誤)

這樣就可以使用mail函數了

<?php
mail("[email protected]","Test mail function of PHP.","hello world!");
?>

❹ php怎麼實現發送郵件

PHP發送郵件是「非常的簡單」 因為他提供了mail()函數直接發送,但配置相當麻煩 (1)通過mail()函數發送郵件 mail() 配置PHP.ini 郵件信息 需要類似sendmail這樣的組件支持 (2)通過socket通訊,使用SMTP傳輸 socket連接->SMTP通訊->獲取通訊消息->發送 mail函數的使用 mail() 函數允許您從腳本中直接發送電子郵件。 如果郵件的投遞被成功地接收,則返回 true,否則返回 mail(to,subject,message,headers,parameters) socket方式發送原理 給你一個別人寫好的類 用法在下面 本人經測試很多網站都不提供免費的smtp服務(126、sina、netease 這幾個試過了),騰訊郵箱支持此功能。 用法: <? require_once ('email.class.php'); //########################################## $smtpserver = "smtp.163.com";//SMTP伺服器 $smtpserverport =25;//SMTP伺服器埠 $smtpusermail = "";//SMTP伺服器的用戶郵箱 $smtpemailto = "";//發送給誰 $smtpuser = "";//SMTP伺服器的用戶帳號 $smtppass = "";//SMTP伺服器的用戶密碼 $mailsubject = "PHP100測試郵件系統";//郵件主題 $mailbody = "<h1> 這是一個測試程序 PHP100.com </h1>";//郵件內容 $mailtype = "HTML";//郵件格式(HTML/TXT),TXT為文本郵件 ########################################## $smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//這裡面的一個true是表示使用身份驗證,否則不使用身份驗證. $smtp->debug = FALSE;//是否顯示發送的調試信息 $smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype); ?> 郵件發送類 <? class smtp { /* Public Variables */ var $smtp_port; var $time_out; var $host_name; var $log_file; var $relay_host; var $debug; var $auth; var $user; var $pass; /* Private Variables */ var $sock; /* Constractor */ function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass) { $this->debug = FALSE; $this->smtp_port = $smtp_port; $this->relay_host = $relay_host; $this->time_out = 30; //is used in fsockopen() # $this->auth = $auth;//auth $this->user = $user; $this->pass = $pass; # $this->host_name = "localhost"; //is used in HELO command $this->log_file =""; $this->sock = FALSE; } /* Main Function */ function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "") { $mail_from = $this->get_address($this->strip_comment($from)); $body = ereg_replace("(^|(\r\n))(\\.)", "\\1.\\3", $body); $header .= "MIME-Version:1.0\r\n"; if($mailtype=="HTML"){ $header .= "Content-Type:text/html\r\n"; } $header .= "To: ".$to."\r\n"; if ($cc != "") { $header .= "Cc: ".$cc."\r\n"; } $header .= "From: $from<".$from.">\r\n"; $header .= "Subject: ".$subject."\r\n"; $header .= $additional_headers; $header .= "Date: ".date("r")."\r\n"; $header .= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n"; list($msec, $sec) = explode(" ", microtime()); $header .= "Message-ID: <".date("YmdHis", $sec).".".($msec*1000000).".".$mail_from.">\r\n"; $TO = explode(",", $this->strip_comment($to)); if ($cc != "") { $TO = array_merge($TO, explode(",", $this->strip_comment($cc))); } if ($bcc != "") { $TO = array_merge($TO, explode(",", $this->strip_comment($bcc))); } $sent = TRUE; foreach ($TO as $rcpt_to) { $rcpt_to = $this->get_address($rcpt_to); if (!$this->smtp_sockopen($rcpt_to)) { $this->log_write("Error: Cannot send email to ".$rcpt_to."\n"); $sent = FALSE; continue; } if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) { $this->log_write("E-mail has been sent to <".$rcpt_to.">\n"); } else { $this->log_write("Error: Cannot send email to <".$rcpt_to.">\n"); $sent = FALSE; } fclose($this->sock); $this->log_write("Disconnected from remote host\n"); } echo "<br>"; echo $header; return $sent; } /* Private Functions */ function smtp_send($helo, $from, $to, $header, $body = "") { if (!$this->smtp_putcmd("HELO", $helo)) { return $this->smtp_error("sending HELO command"); } #auth if($this->auth){ if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))) { return $this->smtp_error("sending HELO command"); } if (!$this->smtp_putcmd("", base64_encode($this->pass))) { return $this->smtp_error("sending HELO command"); } } # if (!$this->smtp_putcmd("MAIL", "FROM:<".$from.">")) { return $this->smtp_error("sending MAIL FROM command"); } if (!$this->smtp_putcmd("RCPT", "TO:<".$to.">")) { return $this->smtp_error("sending RCPT TO command"); } if (!$this->smtp_putcmd("DATA")) { return $this->smtp_error("sending DATA command"); } if (!$this->smtp_message($header, $body)) { return $this->smtp_error("sending message"); } if (!$this->smtp_eom()) { return $this->smtp_error("sending <CR><LF>.<CR><LF> [EOM]"); } if (!$this->smtp_putcmd("QUIT")) { return $this->smtp_error("sending QUIT command"); } return TRUE; } function smtp_sockopen($address) { if ($this->relay_host == "") { return $this->smtp_sockopen_mx($address); } else { return $this->smtp_sockopen_relay(); } } function smtp_sockopen_relay() { $this->log_write("Trying to ".$this->relay_host.":".$this->smtp_port."\n"); $this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out); if (!($this->sock && $this->smtp_ok())) { $this->log_write("Error: Cannot connenct to relay host ".$this->relay_host."\n"); $this->log_write("Error: ".$errstr." (".$errno.")\n"); return FALSE; } $this->log_write("Connected to relay host ".$this->relay_host."\n"); return TRUE;; } function smtp_sockopen_mx($address) { $domain = ereg_replace("^.+@([^@]+)$", "\\1", $address); if (!@getmxrr($domain, $MXHOSTS)) { $this->log_write("Error: Cannot resolve MX \"".$domain."\"\n"); return FALSE; } foreach ($MXHOSTS as $host) { $this->log_write("Trying to ".$host.":".$this->smtp_port."\n"); $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out); if (!($this->sock && $this->smtp_ok())) { $this->log_write("Warning: Cannot connect to mx host ".$host."\n"); $this->log_write("Error: ".$errstr." (".$errno.")\n"); continue; } $this->log_write("Connected to mx host ".$host."\n"); return TRUE; } $this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).")\n"); return FALSE; } function smtp_message($header, $body) { fputs($this->sock, $header."\r\n".$body); $this->smtp_debug("> ".str_replace("\r\n", "\n"."> ", $header."\n> ".$body."\n> ")); return TRUE; } function smtp_eom() { fputs($this->sock, "\r\n.\r\n"); $this->smtp_debug(". [EOM]\n"); return $this->smtp_ok(); } function smtp_ok() { $response = str_replace("\r\n", "", fgets($this->sock, 512)); $this->smtp_debug($response."\n"); if (!ereg("^[23]", $response)) { fputs($this->sock, "QUIT\r\n"); fgets($this->sock, 512); $this->log_write("Error: Remote host returned \"".$response."\"\n"); return FALSE; } return TRUE; } function smtp_putcmd($cmd, $arg = "") { if ($arg != "") { if($cmd=="") $cmd = $arg; else $cmd = $cmd." ".$arg; } fputs($this->sock, $cmd."\r\n"); $this->smtp_debug("> ".$cmd."\n"); return $this->smtp_ok(); } function smtp_error($string) { $this->log_write("Error: Error occurred while ".$string.".\n"); return FALSE; } function log_write($message) { $this->smtp_debug($message); if ($this->log_file == "") { return TRUE; } $message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message; if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) { $this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n"); return FALSE; } flock($fp, LOCK_EX); fputs($fp, $message); fclose($fp); return TRUE; } function strip_comment($address) { $comment = "\\([^()]*\\)"; while (ereg($comment, $address)) { $address = ereg_replace($comment, "", $address); } return $address; } function get_address($address) { $address = ereg_replace("([ \t\r\n])+", "", $address); $address = ereg_replace("^.*<(.+)>.*$", "\\1", $address); return $address; } function smtp_debug($message) { if ($this->debug) { echo $message."<br>"; } } function get_attach_type($image_tag) { // $filedata = array(); $img_file_con=fopen($image_tag,"r"); unset($image_data); while ($tem_buffer=AddSlashes(fread($img_file_con,filesize($image_tag)))) $image_data.=$tem_buffer; fclose($img_file_con); $filedata['context'] = $image_data; $filedata['filename']= basename($image_tag); $extension=substr($image_tag,strrpos($image_tag,"."),strlen($image_tag)-strrpos($image_tag,".")); switch($extension){ case ".gif": $filedata['type'] = "image/gif"; break; case ".gz": $filedata['type'] = "application/x-gzip"; break; case ".htm": $filedata['type'] = "text/html"; break; case ".html": $filedata['type'] = "text/html"; break; case ".jpg": $filedata['type'] = "image/jpeg"; break; case ".tar": $filedata['type'] = "application/x-tar"; break; case ".txt": $filedata['type'] = "text/plain"; break; case ".zip": $filedata['type'] = "application/zip"; break; default: $filedata['type'] = "application/octet-stream"; break; } return $filedata; } } ?>

❺ Postfix郵件伺服器和PHP配合

不知道您為什麼要自己搭建郵件伺服器+web郵箱系統。對新手而言,是一件挺有挑戰性的事情。
郵件伺服器一般我們會考慮網路上很多免費的,它們一般技術成熟,伺服器穩定,而且都是免費的。您架設的,質量上不一定比它們更好。
而web郵箱管理系統,目前也有很多。對今天的用戶而言,也沒有太多吸引力,因為有很多的替代品。微軟的outlook,國產的foxmail都有多年的歷史,也很優秀。而現在移動互聯網時代,手機App也很有優勢。
我猜測,您是不是想讓會員在站內發簡訊?這跟郵件是兩碼事。
或者,您只是想通過php系統,給會員的郵箱發郵件?這用不著您架設郵件伺服器。
當然,您可能愛上了Postfix,因為偶爾得到一個別致的領帶胸針,最後為它配了一整套的西裝革履也有可能。
好吧,我來回答您的問題。
1、如何對Postfix收到郵件進行管理?
您需要編寫基本的兩個程序,收和發。收和發的代碼,比比皆是,代碼並不復雜。但是您要弄清楚架構。
您的郵件伺服器和郵件用戶代理伺服器(會員系統)在同一個主機上,但您得想成是兩個服務,兩個系統。就是說,您收郵件時候,讀取到郵件後,將數據存到會員系統的mysql上。這個郵件在這台伺服器上實際上有兩份了。一般伺服器軟體不會用到mysql,郵件以其他形式在硬碟上存儲。
發郵件,您可以通過您Postfix提供的smtp服務往外發。數據您自己通過php程序保留一份,在您會員系統的mysql里。Postfix沒必要保留發出去的郵件。
2.mysql在這裡面的角色是不是只管理用戶的帳號密碼信息?

如上所述,mysql當然要保留用戶的帳號密碼信息。但不僅如此,要保留發件的內容,還要放收到的郵件內容。
3.對於新手來說怎樣做最容易達到預期效果。

萬能的網路,一切用現成的就好。
您找到了Postfix,這是郵件伺服器。這個架設也不難,網上教程比比皆是。
如果只想做郵件,不想其他的,您搜一個免費的Webmail在線郵件系統就好了。英文的較多,自己做一下漢化。PostfixAdmin可以研究下,它可以和Postfix實現mysql數據共享。
中文的,extmail比較有名,它是一個套件,什麼都有,包括Postfix,拿來研究下直接用,無需二次開發。

❻ php怎麼通過第三方郵件伺服器來發送郵件

用 PHPMailer ,這是一個郵件發送插件,到網上下載一個,具體的使用官網有方法的,很簡單。
swiftMailer 也可以的。
php自帶的mailer方法需要系統的支持,如果是linux的話可以直接使用,而windows就麻煩了,就用上面說的兩個插件中的任何一個就行了,

❼ 用hmailserver+PHP+mysql建了一個郵件系統。60多帳號,全用OE客戶端.有部分可以收,有部分收不到

自己的郵件伺服器很難保證郵件的到達率,建議使用第三方郵件服務提供商(ESP)

Amazon SES (http://aws.amazon.com/ses/)
PostMark (http://www.postmarkapp.com/)
CritSend (http://www.critsend.com/)
SendGrid (http://sendgrid.com/)
SocketLabs (http://www.socketlabs.com/)
MailChimp (http://www.mailchimp.com/)

❽ 請問一下,PHP配置SMTP怎麼弄

PHPMailer的獲取:

PHPMailer項目地址:PHPMailer 使用git命令克隆到本地,或直接在該項目頁面的右下方點擊「 Download ZIP 」即可獲取到完整的PHPMailer代碼包,再到本地解壓即可。

步驟一:使我們的QQ郵箱能夠發送郵件

這里怎麼說能夠發送郵件呢?其實我們的郵箱都是可以發送郵件的,但是要實現在我們的網站中發送郵件,那就要設置一下我們的QQ郵箱了,因為此時我們的網站現在是作為一個第三方客戶端存在的。

步驟一:使我們的QQ郵箱能夠發送郵件

這里怎麼說能夠發送郵件呢?其實我們的郵箱都是可以發送郵件的,但是要實現在我們的網站中發送郵件,那就要設置一下我們的QQ郵箱了,因為此時我們的網站現在是作為一個第三方客戶端存在的

閱讀全文

與php搭建郵件伺服器相關的資料

熱點內容
pythonswampy示例 瀏覽:95
有沒有什麼語音講書看書的app 瀏覽:995
文件夾怎麼做標題 瀏覽:33
騰訊雲伺服器如何防止被攻擊 瀏覽:881
六稜柱的體積演算法 瀏覽:935
淘寶什麼雲伺服器好用 瀏覽:340
pythonoa項目 瀏覽:307
android杜比音效 瀏覽:341
殺手47為什麼連接不了伺服器 瀏覽:108
靜態路徑命令 瀏覽:533
一直編譯不過怎麼辦 瀏覽:829
汽車串聯並聯演算法 瀏覽:458
助眠解壓的聲音音頻小哥哥 瀏覽:277
pythoncmd換行 瀏覽:376
linux取消行號 瀏覽:355
安卓原生系統官網是什麼 瀏覽:444
底部主圖源碼 瀏覽:878
伺服器崩了有什麼提示 瀏覽:780
遠程海康伺服器用什麼瀏覽器 瀏覽:232
解壓報紙圖片 瀏覽:956