Skip to main content
Participant
April 3, 2013
Question

Emails - PHP and Dreamweaver

  • April 3, 2013
  • 3 replies
  • 2651 views

I have made good progress with David Powers 'Training from the Source' until Chapter 8 - Emails.

I have the following message from the Mail Connector

Fatal error: Class 'Zend_Mail_Transport_Sendmail' not found inC:\Xampp\xampp\htdocs\phpcs5\lesson08\workfiles\scripts\mail_connector.php on line 7

The details I entered were as as follows:

<?php

$mailhost = 'smtp.btconnect.com';

$mailconfig = array('auth' => 'login',

'username' => 'mrwhitegrassroot@btconnect.com',

'password' => '************',

'ssl' => 'ssl');

$transport = new Zend_Mail_Transport_Sendmail('-fmrwhitegrassroot@btconnect.com');

Zend_Mail::setDefaultTransport($transport);

I have blotted out my password but I don't think that is the problem.

I currently have one active website on my remote server but that is a static site.

I tried to test the remote server without success probably because it is not linked up to PHP.

Could it be that the emails will not work until I have a remote server that is favourable to PHP?

This topic has been closed for replies.

3 replies

David_Powers
Inspiring
April 7, 2013

Moved to the Develop server-side applications in Dreamweaver forum.

Loftynorman wrote:

I have the following message from the Mail Connector

Fatal error: Class 'Zend_Mail_Transport_Sendmail' not found inC:\Xampp\xampp\htdocs\phpcs5\lesson08\workfiles\scripts\mail_connector .php on line 7

The error message tells you that the script cannot find the Zend_Mail_Transport_Sendmail class. This means that the Zend Framework is probably not in your PHP include path. See page 222 for details of how to set up the include path.

sudarshan.t
Inspiring
April 4, 2013

Can you add this to your code:

'ssl' => 'ssl',

'port' => '465');

Notice I've removed closing bracket next to ssl and replaced with comma. Added Port line and included closing bracket.

Also where are you calling your mail_connector.php script from? YOu should have it somewhere in your code where you say require_once or include_once... Can you post that as well for us please?

Participant
April 5, 2013

Hi Sudarshan,

The error message was removed from the mail connector with the addition of the Port.

I received the following error message on the Feedback Form

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() inC:\Xampp\xampp\php\PEAR\Zend\Mail\Transport\Sendmail.php on line 98
Unable to send mail

I think this is because I was not on the remote server  - where I have a static website.

In response to your request re: require_once see below:

<?php
require_once('C:/Xampp/xampp/htdocs/phpcs5/lesson08/workfiles/scripts/library.php');
$errors = array();
try {
$public_key = '6Lfx_94SAAAAAJw0zHCQ8cpFhiCqs62O-2gGrEUI';
$private_key = '6Lfx_94SAAAAAJvjKoeCiNh1cCM3dJ2Xq1ibX5a9 ';
  $recaptcha = new Zend_Service_ReCaptcha($public_key, $private_key);
  if (isset($_POST['send'])) {
// validate the user input
if (empty($_POST['recaptcha_response_field'])) {
   $errors['recaptcha'] = 'reCAPTCHA field is required';
} else {
   $result = $recaptcha->verify($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
   if (!$result->isValid()) {
  $errors['recaptcha'] = 'Try again';
   }
}
$val = new Zend_Validate_Alnum(TRUE);
if (!$val->isValid($_POST['name'])) {
   $errors['name'] = 'Name is required';
}
$val = new Zend_Validate_EmailAddress();
if (!$val->isValid($_POST['email'])) {
   $errors['email'] = 'Email address is required';
}
$val = new Zend_Validate_StringLength(10);
if (!$val->isValid($_POST['comments'])) {
   $errors['comments'] = 'Required';
}
if (!$errors) {
      // create and send the email
      require_once('mail_connector.php');
      $mail = new Zend_Mail('UTF-8');
      $mail->addTo(
'grassrootspublications@btconnect.com');
      $mail->setFrom(
'mrwhitegrassroot@btconnect.com');
      $mail->setSubject('Comments from feedback form');
      $mail->setReplyTo($_POST['email'], $_POST['name']);
      $text = "Name: {$_POST['name']}\r\n\r\n";
      $text .= "Email: {$_POST['email']}\r\n\r\n";
      $text .= "Comments: {$_POST['comments']}";
      $html = '<html><head><title>';
      $html .= $mail->getSubject();
      $html .='</title></head><body>';
      $html .= "<p><strong>Name: </strong><a href='mailto::{$_POST['email']}'>{$_POST['name']}</a></p>";
      $html .= '<p><strong>Comments: </strong>' . nl2br($_POST['comments']) . '</p>';
      $html .= '</body><html>';
      $mail->setBodyText($text, 'UTF-8');
      $mail->setBodyHtml($html, 'UTF-8');
      $success = $mail->send();
      if (!$success) {
       $errors = TRUE;
      }
}
}
  }catch (Exception $e) {
  echo $e->getMessage();
}
?>

I will be able to work on this more over the weekend.

Graham

Participant
April 7, 2013

Since you're testing locally, you probably dont have a mailserver on your local computer - which is why you're seeing that error.

Try it on your remote webserver. Or, from your local computer, change 'localhost' to a proper mailserver's IP or CNAME (mail.yourdomain.com) or something similar and test it out.


Hello Sudarshan,

I have tried your suggestions apart from the CName.

The remote server where I have a static site came up with the Internet 404 error. When I changed the details locally I received the same error message as before

When I tried to find my mailserver IP all I got was my computer's IP. Then when I checked the properties of some of my normal email messages I noted that 127.0.01 is listed.

I also checked my mail servers:

Incoming Mail (POP3): pop.outlook.com

Outgoing Mail (SMTP): smtp.outlook.com

Port numbers: Incoming: 995

                     Outgoing: 587

I changed the Local Host details in the Library

Hope this information helps as I am sure I am missing something very small but important

Thanks

Graham

mhollis55
Inspiring
April 3, 2013

Does your server have the ability to send email? Does it allow for secure sending?

This is what I do:

$todayis = date("l, F j, Y, g:i a") ;

$subject = Contact_From_Website;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n

Message: $notes \n

From: $visitor ($visitormail)\n

Telephone: $visitorphone ($visitorphone)\n

Additional Info : IP = $ip \n

";

$from = "From: $visitormail\r\n";

mail("youremail@company.com", $subject, $message, $from);

?>