...

View Full Version : PHP mail() function help



poysyn
01-16-2010, 08:51 AM
I am having a mental breakdown with this, I installed PEAR v 1.4.1.1 and I'm using gmail as my smtp server, and i still get this error:


Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\bin\php\php5.3.0\PEAR\Mail.php on line 154

line 154 in Mail.php is:

$parser = &new Mail_RFC822();

PLEASE, ANY INPUT WOULD BE MONUMENTALLY APPRECIATED.

Thank you in advance =)
poysyn.

Here is the form:




<?php

if(!isset($_POST['textname'])) {

$call_query = mysql_query("SELECT * FROM accounts ORDER BY id ASC");
echo '<div align="center" class="title">TEZ Employee Call List</div><br />
<form method="post" action="usercp.php?page=employee_call_list">';
echo '<table align="center" cellspacing="0" cellpadding="5" width="100%">
<tr><td class="tableTL" width="33%"><b>Name</b></td><td class="tableTM" width="33%"><b>Phone Number</b></td><td class="tableTR" width="34%"><b>Alt. Phone Number</b></td></tr>';
while($call_data = mysql_fetch_array($call_query)){
$callName = $call_data['name'];
$call1 = $call_data['acode'];
$call2 = $call_data['first3'];
$call3 = $call_data['last4'];
$calltext = $call_data['text'];
$altcall1 = $call_data['altacode'];
$altcall2 = $call_data['altfirst3'];
$altcall3 = $call_data['altlast4'];
$altcalltext = $call_data['alttext'];

if($calltext == '1'){
$yes = '1';
} else {
$yes = '0';
}

if($altcalltext == '1'){
$altyes = '1';
} else {
$altyes = '0';
}
?>

<tr>

<td class="tableL"><?php echo $callName; ?></td>
<td class="tableM"><?php echo $call1 . '-' . $call2 . '-' . $call3 . '<br />';
if($calltext == '1'){
echo '<form method="post" action="usercp.php?page=employee_call_list">
<input type="hidden" name="name13" value="' . $callName . '" />
<input type="hidden" name="number" value="' . $call1 . $call2 . $call3 . '" />
<input type="submit" name="textname" value="Text" />';
}
?>
</td>

<td class="tableR"><?php echo $altcall1 . '-' . $altcall2 . '-' . $altcall3 . '<br />';
if($altcalltext == '1'){
echo '<form method="post" action="usercp.php?page=employee_call_list">
<input type="hidden" name="name13" value="' . $callName . '" />
<input type="hidden" name="altnumber" value="' . $altcall1 . $altcall2 . $altcall3 . '" />
<input type="submit" name="alttextname" value="Text" />';
}
}
?>

</tr>
<?php
echo '</table>';

} if(isset($_POST['textname'])){

$callNames = $_POST['name13'];
$emp_query = mysql_query("SELECT * FROM accounts WHERE name = '$username'");
$emp_data = mysql_fetch_array($emp_query);
$emp2_query = mysql_query("SELECT * FROM accounts WHERE name = '$callNames'");
$emp2_data = mysql_fetch_array($emp2_query);

if(isset($_POST['number'])){

$to = $_POST['number'];

?>

<form method="post" action="usercp.php?page=employee_call_list">
<table width="400">
<tr>
<td align="right" valign="top">From:</td>
<td align="left"><input type="hidden" name="from" value="<?php echo $emp_data['name']; ?>" /><?php echo $emp_data['name']; ?></td>
</tr>
<tr>
<td align="right" valign="top">To:</td>
<td align="left">
<input type="hidden" name="to" value="<?php echo $to; ?>" />
<input type="hidden" name="tocarrier" value="<?php echo $emp2_data['carrier']; ?>" /><?php echo $callNames; ?></td>
</tr>
<tr>
<td align="right" valign="top">Message:</td>
<td align="left"><textarea name="message" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="textsubmit" value="Send" /></td>
</tr>
</table>
</form>

<?php
}
} else if(isset($_POST['alttextname'])){

$altcallNames = $_POST['name12'];
$emp_query = mysql_query("SELECT * FROM accounts WHERE name = '$username'");
$emp_data = mysql_fetch_array($emp_query);
$emp2_query = mysql_query("SELECT * FROM accounts WHERE name = '$callNames'");
$emp2_data = mysql_fetch_array($emp2_query);

if(isset($_POST['number'])){

$to = $_POST['number'];

?>

<form method="post" action="usercp.php?page=employee_call_list">
<table width="400">
<tr>
<td align="right" valign="top">From:</td>
<td align="left"><input type="hidden" name="from" value="<?php echo $emp_data['name']; ?>" /><?php echo $emp_data['name']; ?></td>
</tr>
<tr>
<td align="right" valign="top">To:</td>
<td align="left"><input type="hidden" name="to" value="<?php echo $to; ?>" /><input type="hidden" name="tocarrier" value="<?php echo $emp2_data['carrier']; ?>" /><?php echo $callNames; ?></td>
</tr>
<tr>
<td align="right" valign="top">Message:</td>
<td align="left"><textarea name="message" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="textsubmit" value="Send" /></td>
</tr>
</table>
</form>

<?php
}
}
include('includes/texting.php');
echo '</form>';



And here is the handler:




<?php


if(isset($_POST['textsubmit'])){

require_once "Mail.php";

$smtphost = "smtp.gmail.com";
$smtpport = "465";
$smtpusername = "********"; //censored for posting
$smtppassword = "********"; //censored for posting

$smtp = Mail::factory('smtp',
array ('host' => stripslashes($smtphost),
'port' => stripslashes($smtpport),
'auth' => true,
'username' => stripslashes($smtpusername),
'password' => stripslashes($smtppassword)));


$from = $_POST['from'];
$getnamefrom = mysql_fetch_array(mysql_query("SELECT * FROM accounts WHERE name = '$from'"));
$firstname = $getnamefrom['first'];
$lastname = $getnamefrom['last'];
$tonumber = $_POST['to'];
$carrier = $_POST['tocarrier'];
$message = stripslashes($_POST['message']);
$from2 = $firstname . $lastname;
$subject = "Sent from the site";
$headers = array ('From' => $from2 ."\r\n", 'Subject' => $subject ."\r\n");

$stop = "false";

echo '<div align="center">';

if (empty($message)) {
echo '<font color="red">Please type a message.</font>';
$stop = "true";
}

else if ($carrier == "Verizon") {
$formatted_number = $tonumber."@vtext.com";
$smtp->send($formatted_number, $headers, $message);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo '<font color="green">message sent successfully!</font>';
}
$stop = "true";
}

else if ($carrier == "TMobile") {
$formatted_number = $tonumber."@tomomail.net";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Sprint") {
$formatted_number = $tonumber."@messaging.sprintpcs.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "ATT") {
$formatted_number = $tonumber."@txt.att.net";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Virgin") {
$formatted_number = $tonumber."@vmobl.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Alltel") {
$formatted_number = $tonumber."@messaging.alltel.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Boost") {
$formatted_number = $tonumber."@myboostmobile.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Helio") {
$formatted_number = $tonumber."@messaging.sprintpcs.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Nextel") {
$formatted_number = $tonumber."@messaging.nextel.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "Metro") {
$formatted_number = $tonumber."@mymetropcs.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

else if ($carrier == "PacBell") {
$formatted_number = $tonumber."@mobile.mycingular.com";
mail($formatted_number, $subject, $message);
echo '<font color="green">message sent successfully!</font>';
$stop = "true";
}

echo '</div>';

}

?>

Dormilich
01-16-2010, 09:04 AM
the solution is quite simple, remove the reference operator, it is not needed as of PHP 5.


$parser = new Mail_RFC822();

poysyn
01-16-2010, 09:09 AM
the solution is quite simple, remove the reference operator, it is not needed as of PHP 5.


$parser = new Mail_RFC822();

remove that whole line, or just the $ symbol before new?

abduraooft
01-16-2010, 09:26 AM
$parser = &new Mail_RFC822();

remove that whole line, or just the $ symbol before new? That isn't $ symbol! It's the ampersand(&).

poysyn
01-16-2010, 10:13 PM
Ok, now that i have deleted the & symbol. it doesnt give me any error messages, and it doesnt send the email. Is there any way to make it actually send the email?

Any Help is greatly appreciated
Thanks In advance =)
poysyn.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum