TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   SMTP or PHP mailing? (http://www.talkphp.com/advanced-php-programming/1839-smtp-php-mailing.html)

ReSpawN 01-01-2008 08:30 PM

SMTP or PHP mailing?
 
Another question on the whole mailing concept.

I've noticed that mail() takes up to 0.7 seconds of your script to send it. I believe that it's because it waits for confirmation.

Now, there are certain mail servers which you access. For example, I am using with my localhost the ISP host. That's the one who provides my Internet, for those who don't know.

Now, I've heard that PHP makes sure that the mails are being sent. Next to that, there are certain programs that allow instant sending (large newsletters, also phpBB uses it) in an instant. When the script is executed, it's all up to the mailserver. Then you're going on to the whole idea of spamming. People imput sleep(#); between the for loops to send emails. This is to prevent an overload and to prevent the mailserver from complaining.

Anyways, now the question is, how hard is it to make your own. I've seen scripts like phpMailer and SwiftMailer, but I rather create my own. Not only to gain in-depth knowledge but I like the challenge as well. That way, I do not have to rely on other systems to do your job for ME. (like lawyers...)

Can you guys give me some possibilities here? Since I am out of options and everytime I send a mail, I am annoyed by the load time.

Mark

Wildhoney 01-01-2008 08:41 PM

Quite simply really. Probably the best way is to connect using fsockopen and then send the data using fputs/fwrite. SMTP, as it's a protocol, has commands such as: HELO TalkPHP.

You'll be able to find the RFC for the SMTP protocol in many locations, though I don't know its RFC number off hand. Even HowStuffWorks, if you go to the "How Email Works" article - that will give you a basic run down of how to send an email using SMTP via Telnet on the 3rd or 4th page in the article; if I remember rightly. Same principle applies to sending the email through a PHP script.

ReSpawN 01-01-2008 09:15 PM

If I understand it correctly, you simply open fsockopen and send with the fputs/fwrite the command EHLO or HELO with after that the domain?
  • HELO - introduce yourself
  • EHLO - introduce yourself and request extended mode
  • MAIL FROM: - specify the sender
  • RCPT TO: - specify the recipient
  • DATA - specify the body of the message (To, From and Subject should be the first three lines.)
  • RSET - reset
  • QUIT - quit the session
  • HELP - get help on commands
  • VRFY - verify an address
  • EXPN - expand an address
  • VERB - verbose
But how does it go from there? I know it accepts commands like MAIL and such but how do you lay the connection and really send the mail. Maybe someone can type it out for moi?


All times are GMT. The time now is 10:39 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0