如何使用 PHP 构建基于 Web 的电子邮件客户端?

发布于 2024-07-26 11:51:56 字数 110 浏览 6 评论 0原文

我想学习如何用 PHP 构建一个基于网络的电子邮件客户端(类似于 yahoo 和 gmail)。

有谁知道我如何开始使用这个?

我希望我的系统能够发送和接收电子邮件。

I would like to learn how to build a web-based email client in PHP (similar to yahoo and gmail).

Does anyone know how I can get started with this?

I would like my system to be able to send and receive email.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

我也只是我 2024-08-02 11:51:57

您可以使用 PHP IMAP 函数轻松构建一个简单的,但如果您必须询问,那么可能会有点麻烦对你来说很复杂。

您是否考虑过使用预建的:

You can build a simple one quite easily using the PHP IMAP functions but if you have to ask then it might be a bit complicated for you.

Have you considered using a pre-built one:

一生独一 2024-08-02 11:51:57

这是一个很大的问题!

您的主要选择是
1. 直接将您的代码与现有邮件服务器集成
2. 使用 IMAP 和 SMTP 与现有邮件服务器通信

第 2 点是最简单的,因为您可以根据需要更改邮件服务器。

是的,还有很多事情需要考虑

Thats a HUGE question!

Your main options are
1. Directly integrating your code with an existing mail server
2. Using IMAP and SMTP to talk to an existing mail server

Number 2 is the most straightforward because you can change mail servers if you ever need to.

and yes there's a lot more to consider as you go

ら栖息 2024-08-02 11:51:57

设置可通过 POP 访问的电子邮件帐户(例如:gmail)。 然后使用 PHP IMAP 函数通过 POP 协议检索电子邮件(POP 可能比 IMAP 更容易)(https:// www.php.net/imap)。 要发送邮件,请使用 PHP 邮件函数 (https://www.php.net/mail) 。

Set up an email account that can be accessed via POP (example: gmail). Then use the PHP IMAP functions to retrieve email via the POP protocol (POP is probably easier than IMAP) (https://www.php.net/imap). For sending mail, use the PHP Mail functions (https://www.php.net/mail).

场罚期间 2024-08-02 11:51:57

最明显的答案应该是“很棒”。

我同意。 对于目前我们所坚持的所谓最性感的界面,很明显我们需要一些不同的东西。 对于那些认为我喜欢发明轮子的人:我不喜欢! 我刚刚安装了一个新网站,我对结果非常满意。 我基本上使用了 1000 个小时的免费开发人员工作,并且不愿意重新发明以前已经做过的、比以前好 1000 倍的东西。 我会用现在的 10% 来设计一个网站,并且会花费 10 倍的时间。 布局很棒,功能也很棒。 我有身份验证、Facebook 类型的社交网络、供我和我的家人存储文件的私人区域、议程、照片和视频支持、YouTube 集成、Facebook 集成……我会有更多,我会添加游戏等等。所有这些几乎都是免费的(我确实在 facebook 类型的社交网络上花费了大约 100 美元)。 如何:joomla。 开源,大量插件。 成千上万的开发人员、设计师、测试人员等的工作。我自己永远无法做到这一点,我也无法永远支付费用。 但它是免费的,所以我不需要。 顺便说一句:joomla 只是众多开源 cms 之一。

我找不到的是一个合适的基于网络的电子邮件客户端,它是“性感的”,并且可以在 cms 系统中正确集成。 我找到并购买了一个圆形立方体包装纸,以插入我精彩的网站。 但不幸的是,这个看起来很旧的垃圾电子邮件网络客户端是不正确的。 它很慢,交互很愚蠢,你需要购买昂贵的模板才能使其与移动设备兼容。 它只是不适合。它看起来很旧。

Joomla 附带了很多免费的东西、插件、身份验证、地址簿、多语言、模板、移动设备支持,所有您需要的一个合适的网站。 只需要一些努力将它们粘合在一起(无需软件开发)。

现在我将开发一个插件来与我的邮件服务器交互,然后我很快就完成了。

不要重新发明,但也不要沮丧。

Most obvious answer should be "great".

I agree. With the current so-called-most-sexy interface we're stuck with, it's clear we need something different. For those thinking I like to invent the wheel: I don't! I just installed a new website and I am very satisfied with the result. I basically used 1000s of hours of free developers' work and would hate to re-invent something which has been done before, 1000 times better. I would come up with a website 10% of what I would have right now and would have spend 10 times longer. The layout is great, the functionality is great. I have authentication, a face-book type of social network, private area for me and my family to store files, agenda, photo and video support, youtube integration, facebook integration, ... I will have more, I'll add games, etc. All pretty much for free (I did spent about 100 usd on the facebook-type-of-social network). How: joomla. Open source, loads of plugins. 100s of thousands of developer's work, designers work, testers, etc. I would never be able to do this myself, neither would I be able to pay for ever. But it's for free, so I didn't need to. And by the way: joomla is only one of many open source cms.

What I can't find is a proper web-based email client which is "sexy", and which integrates properly within the cms system. I found and bought a roundcube wrapper, to plug in into my wonderful website. But unfortunatly this very-old-looking-crap-email webclient is just not right. It's slow, the interaction is silly, you need to buy expensive templates to make it work with mobile devices. It just does't fit in. It looks old.

Joomla comes with a lot of free stuff, plugins, authentication, address books, multi language, templates, mobile devices support, ALL you need for a proper website. Just needs a bit of effort to glue it all together (no software development).

Now I will work on a plugin to interact with my mail server, then I have this done in no time.

Don't re-invent, but don't get depressed neither.

久伴你 2024-08-02 11:51:57

If you're not using an external mail service (like Gmail) you will need to configure your own server to store and send email. Here is a tutorial for using Postfix (for sending mail) and Dovecot (for accessing mail via IMAP).
This tutorial also explains setting up a webmail system in SquirrelMail. You could do this, or, if you really want to develop your own system you could write a PHP application to access your mail.

Good Luck!

醉生梦死 2024-08-02 11:51:56

最明显的答案是“不要”:已经有很多网络邮件软件,其中一些是基于 PHP 的(如果您依赖于使用 PHP,因为您已经拥有服务器例如,基于 LAMP 堆栈)

仅引用几个基于 PHP 的名称,您可以查看这些名称:

我已经使用列表中的三个第一相当一段时间了; roundcube 绝对是最“用户友好”,我想说...

(稍微谷歌一下,你可能会发现更多 - 但我想我谈到了那些最常用的)


现在,如果您必须为您的公司设置一个网络邮件:绝对使用一些现有的软件

  • 现有的软件将已经相当“”了:
    • 很多人使用它,这意味着很多人说“这可以做得更好”,或“这对用户不友好”,或者......你明白了; 所有这些都使现有软件变得更好:-)
    • 许多人会尝试破坏这样的应用程序 - 这意味着大量的安全修复,这意味着应用程序可能比您在很长一段时间内编写的应用程序更安全......
  • 现有的开源应用程序将代表数百天的工作
    • 您真的准备好花这么多时间研究已经存在的事情了吗?
    • 如果您在一家公司工作:您的公司准备好支付您一年的工资吗? 或者甚至可能更多?正在研究已经存在的东西?
    • 你不相信我吗? 阅读这篇博文:代码:很简单; 它是关于 Stack Overflow 的,但对于网络邮件软件来说是完全一样的(除了 Stack Overflow 更新——并且可能有更少的代码贡献者;但这只是一个疯狂的猜测 ^^

作为旁注:如果你的公司希望你构建 gmail 的克隆,你不会(同样的事情:有多少人在 gmail 上工作?你的公司有多少程序员?你的公司可以在这方面花多少钱?)...

每年只需花费几美元,您的公司就可以为其每位员工拥有一个“专业”Google 帐户,顺便说一句...


毕竟,如果您仍然想/必须使用 LA*(M)*P 堆栈编写自定义的手工 Webmail,您至少需要了解以下内容:

  • 如何用 PHP 进行编程
  • IMAP 的基础知识 (即使您使用库 /框架,这么大的应用程序将要求您了解一些有关底层协议的知识,或者永远无法理解“为什么”或“如何”出了问题)
  • HTML / CSS / JavaScript (有一些AJAX 知识 - 来吧,现在是 2009 年了!)
  • 因此您的应用程序更容易维护(并且可以添加/重新设计/修改内容并纠正错误),您可能会想要使用一些框架,并遵循一些设计模式和最佳实践
    • 作为示例,您可以查看 symfonyZend 框架
    • 是的,您可以在没有框架和/或 MVC 的情况下进行开发和应用...但是..ergh...

考虑到这一切都不是问题(如果您还不太擅长这一切,和/或没有太多经验,那么可能至少需要几年时间才能获得这些...考虑到编程和 Web 开发是您的全职活动),您可以开始考虑使用 IMAP 等方式访问邮件服务器。

这里有几种可能性。

至少在选择之前,我会看看这两个:


一旦您的应用程序完成,您将(希望如此!)开始获得用户,这至少意味着三件事:

  • 错误报告; 对于用户来说,这些几乎总是紧急 - 比如“天哪,我不明白什么都不起作用了,我现在就得收到我的邮件!
  • 进化请求:用户总是想要更多诸如“我在我的个人帐户的 Gmail 中看到了这个;我们的公司帐户怎么没有这个?这是我们用来工作的工具!”“
  • 这太慢了,我无法工作!”; 那么,祈祷您在设计/开发应用程序时考虑到可扩展性和优化!

再次,你准备好应对这个问题了吗?


好吧,我想我说得够多了; 现在,您需要思考:您真的想要/需要从头开始开发这样的应用程序吗?

如果您有一点空闲时间,也许您可以参与一个已经存在的开源项目?这对每个人来说都是有利可图的;-)

Finally, one last thing: **if you want to work on such a project just for fun, to know what it's like, and to learn more about web-development, then DO !**

*(It's, in my opinion, probably the only reason that would justify working on this, BTW)*

Most obvious answer would be "don't": there are already lots of webmail software, some of which are PHP-based (if you depend on using PHP, because you already have a server based on a LAMP stack, for instance).

To quote only a few names, all PHP-based, you could have a look at these ones:

  • SquirrelMail: a quite old-one, and not really sexy... But has been doing the job for years
  • Horde IMP: well-know too, and quite powerful
  • roundcube: maybe the most "sexy" and "web 2.0" of the list of those I tried
  • AtMail: I've never used this one, so I can't say much more...

I've used the three firsts of the list for quite some time ; roundcube was definitely the most "user-friendly", I'd say...

(Googling a bit, you might find many more -- but I think I spoke about the ones that are the most used)


Now, if you have to set up a Webmail, say, for you company: definitely use some already existing software:

  • an existing software would be quite "good" already:
    • many people using it, which means many people who said "this could be done better", or "that is not user-friendly", or... you get the point ; all this made the existing software better :-)
    • many people will have tried to break such an application -- which means lots of security-fixes, which means an application probably more secure than you'll write in a long time...
  • an existing open-source application will represent hundreds of days of work
    • are you really ready to spend that kind of amount of time working on something that already exists?
    • if you're working for a company: is your company ready to pay your for one year? or even probably more ? working on something that already exists?
    • you don't believe me? Read this blog-post: Code: It's Trivial ; it's about Stack Overflow, but it would be exactly the same for a webmail software (except that Stack Overflow is more recent -- and probably had less code-contributors ; but that's just a wild guess ^^ )

As a sidenote: if your company wants you to build a clone of gmail, you won't (same thing: how many people worked on gmail? How many programmers does your company have? How much can your company spend on this? )...

And for just a couple dollars each year, your company could have a "professionnal" Google account for each one of it's employes, BTW...


After all this, if you still want to / have to write a custom hand-made webmail using a LA*(M)*P stack, you will need to know at least the following:

  • How to programm in PHP
  • The basics of IMAP (even if you use a library / framework, such a big application will require you to know some stuff about the underlying protocols, or won't ever understand "why" or "how" something went wrong)
  • HTML / CSS / JavaScript (with some knowledge of AJAX -- come on, it's 2009 !)
  • So your application is easier to maintain (and adding/reworking/modifying stuff and correcting bugs is possible), you will probably want to use some Framework, and follow some design patterns and best practices
    • As an example, you can take a look at Frameworks like symfony, or Zend Framework
    • Yes, you can develop and application without a Framework, and/or without MVC... But.. ergh...

Considering all this is not a problem (If you are not quite good at all this already, and/or don't have much experience, it could take at least a couple of years to acquire that... Considering programming and web-developping is your full-time activity), you can start tkinking about accessing a mail server using, for instance, IMAP.

There are several possibilities here.

I would have a look, at least, before choosing, at these two:


Once your application is quite done, you will (hopefully !) start getting users, which means at least three things:

  • Bug-reports ; those are almost always urgent for users -- like "OMG I don't understand nothing works anymore, I gotta get my mail RIGHT NOW!"
  • Requests for evolutions: users always want more stuff like "I saw that in gmail on my personnal account ; how is it we don't have that too with our corporate account? It's the tool we use to work !"
  • "This is too slow, I can't work !" ; then, pray you thought about scalability and optimization when you designed/developped the application!

Here, again, are you ready to deal with that?


Well, I think I said enough ; now, it's your time to think: do you really want/need to develop such an application from scratch?

If you have a bit of free time, maybe you could participate in an already existing, open-source, project ? That could be profitable to every one ;-)

Finally, one last thing: **if you want to work on such a project just for fun, to know what it's like, and to learn more about web-development, then DO !**

*(It's, in my opinion, probably the only reason that would justify working on this, BTW)*

慵挽 2024-08-02 11:51:56
  1. 学习 Web 堆栈:HTML、javascript、php、mysql...
  2. 编写一些小项目
  3. 受雇向更有经验的人
  4. 学习 学习 OOP、设计模式、最佳实践等
  5. 应用您几年所学

如果您通过了分数5、你就会知道如何建造一个。

  1. Learn the web stack: HTML, javascript, php, mysql...
  2. Write a few small projects
  3. Get hired somewhere to learn from more experienced people
  4. Learn OOP, design patterns, best practices etc
  5. Apply what you learned for a few years

If you pass point 5, you'll know how to build one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文