I know this is possible, but can I do without a remote SMTP server or the like? Basically I want to send mail with PHP, but without mail()
-
your question needs elaboration. via file share and direct access to mbox? – bcosca Nov 04 '10 at 15:08
-
@stillstanding not sure what you mean by file share. dont have direct access to mail box. – Rob Nov 04 '10 at 15:10
-
Do you means "I am a spammer, but my webhosting quota limit `mail()`. How can I override this limit and send my spams?" – J-16 SDiZ Nov 05 '10 at 03:44
-
@J-16 SDiZ, no, what I mean is that I'd like to learn more about sockets and transport protocols, and I thought that sending mail using sockets would be a good place to start. – Rob Nov 05 '10 at 14:50
3 Answers
I'm unsure what you exactly mean with 'without a remote SMTP server', as in any mail delivery at least one of those has to be involved - the one receiving mail on account of the recipient...
What you can probably do (it's up to you to decide if it's worth the effort) is to use PHP's socket functions to open a connection on port 25 with a remote mail server. Google 'SMTP telnet
' for some examples of how a SMTP session looks like (quite simple, to be true) and then google for 'SMTP codes
' for more explanations of what the remote server is saying you.

- 3,950
- 22
- 21
Possible, but not entirely trivial considering the fact that you should be familiar with SMTP, POP3 and/or IMAP to actually exchange data with a mail server.
You need to code your app so it mimics the behavior of an MTA, that is if you're going to do what the mail() function does - and using sockets. If you're on Linux, another option is to make an OS call to sendmail.

- 17,371
- 5
- 40
- 51
-
Right, I've been looking into it. Scratch the localhost:8888 thing (editing question in a sec) Mostly I want to send mail without mail() – Rob Nov 04 '10 at 14:44
To not use mail() look into PHPMailer
I use this library for all my e-mailing code. I've extended it to have a debug mode so I can intercept outgoing e-mails while testing code.
I could be wrong but you will always be using an SMTP server even if that server is just the webserver with sendmail on it. If you were running your PHP on windows you'd need to enable IIS's in built SMTP service.

- 973
- 6
- 15