开发者

What are the requirements to send an email with PHP?

  • I'm developing a Web application with PHP 5.3.3.
  • I want it to send confirmation e-mails automatically.
  • I don't have a domain name yet.
  • I'm using Windows XP.
  • I don't have PEAR's Mail package.
  • I have hMailServer and is the mail server I want to use to send the e-mail开发者_如何转开发s.

My questions are:

  1. Can I send e-mails without a domain name? (Is it absolutely necessary? I just want to test the application for the moment.)
  2. If a domain name is necessary, do I also need to host the application with a Web Hosting Service Provider? Can I do it from my computer?(Remember, I just want to test the application.)
  3. Do I absolutely need the PEAR's mail package? or can I simply use the mail() function?

I'm clueless about what I should do. I've made my research, I understand the parts but I can't make sense of the whole, I mean what resources are necessary and how to put it together. I've never developed any application that sends e-mail before. Please, help me.


  1. Yes. You can set your "from" address to whatever you want. (Though note, the recipient server might detect it's forged and reject it.)

  2. You can host from you computer, just make sure your network is not blocking port 25 outbound.

  3. mail() alone will suffice as long as you have a local SMTP server that will handle your messages. (I'm assuming that's what the hMailServer product is.)


First off, if you're running Windows as your server, you need to configure how your e-mails will be sent (SMTP server). Go to this section in your php.ini file. Change localhost to an SMTP server you can use from your network (either the IP address of your hMailServer OR sometimes you need to purchase one to use like http://www.smtp2go.com/).

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

Second, you use the mail(...) function in php (including the ability to send HTML mail). That's it.


  1. Yes, you can. I believe your emails will show up with your server's DNS by default, but you can set the from: header to whatever you want. However, if you change the from: header, be warned that your emails are likely to get picked off by spam filters.

  2. You need some special server configuration to use the php mail() function - I haven't tried setting it up myself, but I know that a basic local apache / php install won't have the capacity to send emails. Pretty much every paid web server should have it set up properly, though.

  3. No. You can send regular and html emails with the generic mail() function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜