Jump to content

[SOLVED] PHP mail() using PEAR and exchange server, need to add attachments


joosh

Recommended Posts

<?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

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,

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.