Jump to content

PHP, Sending E-Mail, and Exchange Via SSL


criticman

Recommended Posts

I need to send e-mail from our website via our hosted Exchange server, which requires SSL connections (for Outlook 2007, it specifies to use TLS if that matters any)

 

I have the SMTP address for use with the Exchange server.  I can telnet to it on the SSL port (465) from our Linux server and it connects, responds validly as being our Exchange box.  It HAS to be over SSL.  I found an "SSL using PEAR:Mail" tutorial, tried the following:

<?php
// PHP Pear Mail Extension
require_once "Mail.php";

$from = "XYZ <x@yz.net>";
$to = "XYZ <x@yz.net>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "smtp.yz.net";
$port = "465";
$username = "x@yz.net";
$password = "XyZxYz";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
	'port' => $port,
	'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 successfully sent!</p>");
 }
?>

 

And I get the following error:

[pre]authentication failure [sMTP: Invalid response code received from server (code: 530, response: 5.7.0 Must issue a STARTTLS command first)][/pre]

 

Our Exchange provider could care less, as our Outlook and OWA, as well as ActiveSync e-mail is working just fine...

 

I am tired of routing my employer's web email through my personal company's web server (using standard SMTP auth on a Linux box) instead of using their server, especially since users will randomly end up missing a message depending on the receiving mail server and whether or not is says the sender is forged (showing company's email addresses, using my server instead).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.