joosh Posted July 28, 2009 Share Posted July 28, 2009 <?php require_once "Mail.php"; $to = '[email protected]'; $from = '[email protected]'; $subject = $_POST['subject']; $body = $_POST['message']; $host = 'exchange.server.org'; $username = 'username'; $password = 'password'; $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message sent!</p>"); } ?> So here's what I have, and it works (names/addresses have been changed). But I need to add attachments of mime 'application/zip'. Can someone lead me in the right direction? Thanks, Josh Link to comment https://forums.phpfreaks.com/topic/167847-solved-php-mail-using-pear-and-exchange-server-need-to-add-attachments/ Share on other sites More sharing options...
derobee Posted July 28, 2009 Share Posted July 28, 2009 Hi Joosh, I am new to PHP and learning. I want to send mail from my php script which is on localhost via smtp (eg: smtp.google.com) I tried searching, but I could find any successful complete answer. Overview: I am running Apache 2.2 on Windows XP Pro SP3. I have PHP 5.2.9 installed. My php directory: c:\php My project directory : C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Mail Questions : 1) I downloaded PEAR mail package ( Stable version 1.1.14 - a zip file) from http://pear.php.net/package/Mail, Where should I place package.xml file and Mail-1.1.14 folder? 2) Do I have to rename any file/folders? 3) What changes should I make to php.ini, if any? 4) What changes should I make to apache configuration file, if any? If possible can you please give me a detailed setup for sending emails via smtp or a small program calling the function and sending an email from Gmail server, smtp.gmail.com:465/587 will be very helpful or any other example sending email via smtp will be helpful. Thanks, Link to comment https://forums.phpfreaks.com/topic/167847-solved-php-mail-using-pear-and-exchange-server-need-to-add-attachments/#findComment-885316 Share on other sites More sharing options...
joosh Posted July 28, 2009 Author Share Posted July 28, 2009 I am using XAMPP, I do not know anything about PEAR. Please don't jack my thread with your problem. Start your own, but before that, google it or use the search feature here. Link to comment https://forums.phpfreaks.com/topic/167847-solved-php-mail-using-pear-and-exchange-server-need-to-add-attachments/#findComment-885318 Share on other sites More sharing options...
joosh Posted July 29, 2009 Author Share Posted July 29, 2009 I have been working on this all day using many different scripts found while googling. Nothing worked until I found this Pear module called Rmail from PHPGuru.com: http://www.phpguru.org/static/htmlMimeMail5 Works great! Link to comment https://forums.phpfreaks.com/topic/167847-solved-php-mail-using-pear-and-exchange-server-need-to-add-attachments/#findComment-885706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.