The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Send email from php with attachment?


How can I send automated email from php? I've tried the sample code but didn't work. Is SMTP server required?
What other software do I need to make it work?
Wednesday, June 06, 2007
You can do it by hand but you have to learn about the smtp protocol (which can be very useful), or google for phpmailer.
Masiosare Send private email
Wednesday, June 06, 2007
To send mail from PHP you need either an SMTP server or a local sendmail that knows how to get mail out to the internet. See <>. To send mail with attachments you will need something like phpmailer, but I'd suggest getting the built-in mail() function working first.

If that doesn't solve your problem, reply with more details about what you're doing and what goes wrong. Include the code you're using and any error messages produced.
Wednesday, June 06, 2007
You can find out if your PHP installation is already able to use mail() by creating a PHP info page and looking for the `sendmail_path' variable. Mine says `/usr/sbin/sendmail -t -i', so it's ready to go.

// function to display PHP details

Then you can create a mail message pretty simple.

Hope that helps some.
Tim Patterson Send private email
Wednesday, June 06, 2007
Tim: That will give false negatives on systems where PHP is set up to talk directly to an SMTP server, including basically all Windows systems where PHP is correctly set up.
Wednesday, June 06, 2007
Sending mail with PHP? Try SwiftMailer!

Simple attachment sending too! See for sample code.
Wednesday, June 06, 2007
Pear has a couple of really useful Mail classes
Andreas Sikkema Send private email
Thursday, June 07, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz