/    Sign up×
Community /Pin to ProfileBookmark

Trouble sending mail through php page

I have a very simple web form where when the user hits submit, it sends ME an email containing all the info the user entered in the form. My problem is that I cannot get it to send the mail. First of all I should mention that I am just an amateur developer, but do know the basics and “enough to get by”. Also I am hosting my site on my Macbook using Xampp. I got the site up and running just fine, but just cannot get this mail form to work.

What I am using to try to send the mail is php/Pear mail. In my research I figured that I needed PEAR because my ISP “mail server” (excuse my terminology probably being wrong there) requires authentication and the standard php Mail() function does not work with “servers” that require authentication. NOW, I also have a PC with Xampp installed for testing and such, and if I host the same .php file that sends the mail on my PC it works just fine… Well, I should revise that as to it sends the mail, but also displays a dozen or so errors on the page, which I can suppress by changing an error setting in the php.ini file. But when I host the .php file on my Mac’s Xampp server it does NOT send the mail and I get the following error message:

[B]Deprecated:[/B] Assigning the return value of new by reference is deprecated in [B]/Applications/XAMPP/xamppfiles/lib/php/pear/Mail.php [/B]on line 154
Unable to find class for driver smtp

[B]Fatal error:[/B] Call to undefined method PEAR_Error::send() in [B]/Library/Webserver/Documents/mailform.php [/B]on line [B]53[/B]
I have tried to reinstall and restart Xampp,and installed the latest version of PEAR mail, but still no luck. The code I have to send the mail is:

[CODE]
require_once “Mail.php”;

$from = “Joe <[email protected]>”;
$to = “Joe <[email protected]>”;
$subject = “Someone just entered information on your web form”;

$host = “outgoing.verizon.net”;
$username = “username”;
$password = “Password”;

$body = “Form Data:
Name: ” .$_POST[‘Name’].”
City: “.$_POST[‘City’].”
State: “.$_POST[‘State’].”
Email: “.$_POST[’email’].”
Comments: “.$_POST[‘Comments’];

$headers = array (‘From’ => $from,
‘To’ => $to,
‘Subject’ => $subject);
$smtp = Mail::factory(‘smtp’,
array (‘host’ => $host,
‘auth’ => true,
‘username’ => $username,
‘password’ => $password));

$mail = $smtp->send($from, $headers, $body);

if (PEAR::isError($mail)) {
echo(“<p>” . $mail->getMessage() . “</p>”);
} else {
echo(“<p>Message successfully sent!</p>”);
}
[/CODE]

Any suggestions to get this working on my Mac too???

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @jburatti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...