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?

Hello,

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?
Thanks.
j2e
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 <http://us2.php.net/mail>. 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.
clcr
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.

<?php
// function to display PHP details
phpinfo();
?>

Then you can create a mail message pretty simple.

http://us.php.net/manual/en/function.mail.php

http://www.php.net/manual/en/ref.mail.php

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.
clcr
Wednesday, June 06, 2007
 
 
Sending mail with PHP? Try SwiftMailer! http://swiftmailer.org

Simple attachment sending too! See  http://www.swiftmailer.org/wikidocs/v3/tutorials/attachments for sample code.
Bruce
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