dslreports logo
 
    All Forums Hot Topics Gallery
spc
Search similar:


uniqs
875

zacron
Premium Member
join:2008-11-26
Frozen Hoth

3 edits

zacron

Premium Member

Simple Problem

Hello, I am attempting to use PHP to send some data via email after it posts to a db. Is there any reason why the code below isn't sending them email?

Thank you for being my 2nd set of eyes. :) I am killing myself trying to figure this one out.

I think it's to do with the "$message" variable. (2nd post line 64)

<?php
//GET VARIABLES THAT WERE PASSED
$fname = @$_POST['fname'] ;
$lname = @$_POST['lname'];
$dob = @$_POST['dob'] ;
$sex = @$_POST['sex'] ;
$address = @$_POST['address'] ;
$city = @$_POST['city'] ;
$province = @$_POST['province'] ;
$postal = @$_POST['postal'] ;
$telephone = @$_POST['telephone'] ;
$automobile = @$_POST['automobile'] ;
$licence = @$_POST['licence'];
$house = @$_POST['house'] ;
$rentpmt = @$_POST['rentpmt'] ;
$sexok = @$_POST['sexok'] ;
$rooms = @$_POST['rooms'] ;
$coursetype = @$_POST['coursetype'] ;
$cstart = @$_POST['cstart'] ;
$cstop = @$_POST['cstop'] ;
$why = @$_POST['why'] ;
$comments = @$_POST['comments'] ;
$date = @$_POST['date'];
 
 
zacron

zacron

Premium Member

Line 77 Forward.

//CONNECT TO DATABASE SERVER AND DATABASE/TABLE
$con = mysql_connect("localhost","xxx","xxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("tenants", $con);
$sql="INSERT INTO people (id,
fname,
lname,
dob,
sex,
address,
city,
province,
postal,
telephone,
automobile,
licence,
house,
rentpmt,
sexok,
rooms,
coursetype,
cstart,
cstop,
why,
comments,
date)
VALUES('',
'$fname',
'$lname',
'$dob',
'$sex',
'$address',
'$city',
'$province',
'$postal',
'$telephone',
'$automobile',
'$licence',
'$house',
'$rentpmt',
'$sexok',
'$rooms',
'$coursetype',
'$cstart',
'$cstop',
'$why',
'$comments',
'$date')";
 
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<div background-color:#42D53A>Completed!";
 
mysql_close($con)
 
$to = "xxx@xxx.xxx";
$subject = "NEW Tenant Incoming!!";
$email = $_POST['email'] ;
$message = "Prospective Tenant - \n\nName: $fname, $lname\nEmail: $email\nTelephone: $tel\nStreet Address: $address, $city, $postal\nHouse Interested In: $house\n\nNumber of Rooms: $rooms\n\nOK with Different Sexes: $sexok\nFirst and Last?: $rentpmt\n\nCourse Type: $coursetype1\nCourse Start: $cstart\nCourse Stop: $cstop\nWhat do you expect from your landlord? $why\nOther Comments: $comments\n\nDate submitted: $date\n\n";
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "<h1>Thank you for your submission, We will get back to you within 3 business days.</h1>"; }
else
{print "We encountered an error sending your mail"; }
 
?>
 
<!--DISPLAY MENU OPTIONS-->
<html>
<body>
 
<H1>You may wish to call us, please do so at xxxx</h1>
</body>
</html>
 

ekiM5
Oh Well
join:2001-01-06
/usr/home

ekiM5 to zacron

Member

to zacron
Are there errors in your server mail log?

zacron
Premium Member
join:2008-11-26
Frozen Hoth

zacron

Premium Member

This is all I could find:

Nov 22 09:33:11 ubuntu postfix/master[7587]: daemon started -- version 2.8.5, configuration /etc/postfix
Nov 22 09:34:00 ubuntu postfix/smtpd[7596]: connect from localhost[127.0.0.1]
Nov 22 09:34:00 ubuntu postfix/smtpd[7596]: 68A478022E: client=localhost[127.0.0.1]
Nov 22 09:34:00 ubuntu postfix/cleanup[7600]: 68A478022E: message-id=<f4146e08255defba78b6051b051b9f13@xxx>
Nov 22 09:34:00 ubuntu postfix/qmgr[7591]: 68A478022E: from=<xxx@gmail.com>, size=880, nrcpt=1 (queue active)
Nov 22 09:34:00 ubuntu postfix/smtpd[7596]: disconnect from localhost[127.0.0.1]
Nov 22 09:34:01 ubuntu postfix/smtp[7601]: 68A478022E: to=<xxx@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.142.26]:25, delay=1, delays=0.06/0.01/0.39/0.55, dsn=2.0.0, status=sent (250 2.0.0 OK 1353605644 l7si3381077igb.8)
Nov 22 09:34:01 ubuntu postfix/qmgr[7591]: 68A478022E: removed
 
zacron

zacron to ekiM5

Premium Member

to ekiM5
I found this in the apache error log...

[Tue Dec 04 05:40:06 2012] [error] [client 192.168.1.1] PHP Parse error: syntax error, unexpected T_VARIABLE in /var/www/netchecktech/joomla/signup/insert.php on line 86, referer: »snip.snip.snip/joomla/signup/

cdru
Go Colts
MVM
join:2003-05-14
Fort Wayne, IN

cdru to zacron

MVM

to zacron
Have other scripts been able to mail from this server? Does the server have a rDNS entry? Based on your redacted log, you're sending email address is a gmail account and you're sending to an account (possibly the same account). However, I'm going to guess that you're server isn't an authoritative mail server for gmail.

Google doesn't tell you (or at least use to not tell you) when it drops your message. It happily accepts your message and just routes it to /dev/null.

zacron
Premium Member
join:2008-11-26
Frozen Hoth

zacron

Premium Member

yes, I have three others that are working, there is an rdns entry and it's smtp auth however, disabled for testing purposes.

JAAulde
Web Developer
MVM
join:2001-05-09
Frederick, MD
ARRIS SB6141
Ubiquiti EdgeRouter Lite
Ubiquiti UniFi AP

JAAulde to cdru

MVM

to cdru
Edit: This post was made as you were making your last one. My comments probably do not apply given the new info.

In addition, most major hosting companies lock down their systems such that mail leaving the mailer daemons on their machines must be bound for an address on their network. In most cases these days you must set up an email account from which you want mail to be sent, and you need some sort of SMTP mailer code which can reach out to that account's SMTP servers, authenticate, and send the message.

cdru
Go Colts
MVM
join:2003-05-14
Fort Wayne, IN

cdru to zacron

MVM

to zacron
said by zacron:

yes, I have three others that are working, there is an rdns entry and it's smtp auth however, disabled for testing purposes.

Is it sending to and from the same gmail account(s)?
cdru

cdru to zacron

MVM

to zacron
While not related to your current problem, you really need to sanitize your posted values. You're ripe for a SQL injection hack with what you've shown.

zacron
Premium Member
join:2008-11-26
Frozen Hoth

zacron to JAAulde

Premium Member

to JAAulde
I don't think it's the email, I posted the apache error log, it's telling me there's an "Unexpected T_VARIABLE on Line 86" which is the line where the email address is.

I did fix the syntax,

it was a missing semi colon after the "mysql(close);" statement and then the variables were using the wrong marks (") instead of (').

I just got the email from the script.

Thank you for your assistance guys

Zacron