วิธีการรับและแยกการใช้อีเมล POP3 และ PHP

1 มีนาคม, 2010 โดย admin ปล่อยให้ตอบกลับ »

ฉันต้องการจะอธิบายวิธีการบางอย่างกับวิธีการเขียนโปรเซสเซอร์สำหรับอีเมลขาเข้า. ฉันได้ใช้การจัดการดังกล่าว แยกอีเมล ที่ได้รับจากแหล่งต่างๆ. นี้จะมีประโยชน์สำหรับการเขียนระบบกรองอีเมลขยะของคุณเอง, ระบบเครื่องตอบรับหรือตั๋วรับสมัครโดย e - mail.

จะใช้วิธี parser e - mail ที่เราต้องการ

  1. เชื่อมต่อและ log - on กับเซิร์ฟเวอร์อีเมล
  2. นับจำนวนตัวอักษรขาเข้า
  3. recive e - mail จากเซิร์ฟเวอร์ที่ใช้โปรโตคอล POP3
  4. กระบวนการส่วนหัวอีเมลและร่างกายและทำการแยก
  5. … ใช้การดำเนินการเพิ่มเติมใดๆ

Ok, มีงานที่เฉพาะเจาะจงมากคือ PHP การเข้ารหัส, ดังนั้นเราต้องการพื้นที่ที่สนับสนุนการเชื่อมต่อภายนอก. ฉันไม่ได้เสนอการเขียนการตัดสินใจทั้งหมดเพราะมากได้รับการตระหนักโดยโปรแกรมเมอร์มีความสามารถแล้ว. เช่น, คุณสามารถใช้โมดูลพร้อมที่จะให้รับอีเมลจากเซิร์ฟเวอร์ระยะไกล.

ขอบคุณเพื่อ Manuel Lemos และเขามอ (class php) ซึ่งชื่อ pop3.php.

เพื่อเชื่อมต่อชั้นที่ให้รหัสของคุณ, คุณเพียงแค่ต้องใช้รวมหรือต้องการคำสั่ง: ต้องการ(“pop3.php”);


hostname=$hostname;
$result=$pop3_connection->Open();

// We are trying to open connection and display the result
echo $result;
// Trying to logon and display the error if any appear
$error=$pop3_connection->Login($ผู้ใช้,$accesscode,$apop);
ถ้า ($ความผิดพลาด<>'ข้อผิดพลาดรหัสผ่าน: ความล้มเหลวเข้าสู่ระบบ: ไม่ทราบชื่อผู้ใช้หรือรหัสผ่าน bad . ') {echo $error; ทางออก;}
// Now get the statistic how many emails are stored and the size of them $result=$pop3_connection->Statistics($messages, $size);
สะท้อน "$hostname contains  $messages ของ $size bytes.";

//..... มีเราได้รับอีเมลในรอบและแยกพวกเขา .... //

// ถ้าไม่มีอะไร - we can close the connection
$error=$pop3_connection->Close(); //
echo $error;
?>

ตอนนี้เรารู้วิธีการเชื่อมต่อและ log - on กับเซิร์ฟเวอร์ POP3 และวิธีการขอหมายเลขของกล่องจดหมายอีเมลและขนาดนั้น. ถัดไป, เราควรได้รับแต่ละ e - mail และแยกหัวและ array ร่างกาย.

จะต่อเนื่อง

แบ่งปันและสนุกกับ

  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
การโฆษณา

3 แสดงความคิดเห็น

  1. ทอง says:

    ยิ่งใหญ่, ที่จะทำงาน, สิ่งนี้? วิธีการรับอีเมล? parser - mail วิธีการเขียน e? ต่อโปรด, โพสต์มาก!

  2. Waipahu locksmith says:

    Fantastic Post. I have read many posts on this subject and you done the best job. Keep it up!

  3. web application technology says:

    You can not believe just how long ive been googling because of this. Through seven pages of Digg results with out finding anything. 1 search on Msn. There this isGotta start using this more often ebrantley@kc.rr.com

ปล่อยให้ตอบ

คุณจะต้อง เข้าสู่ระบบ เพื่อแสดงความคิดเห็น.