[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

php mail fails

See code (php).

Until yesterday, this worked.

It used to be that $mailto = "richard@rkassociates.com". Yesterday, I added the other email addresses.

Now nothing.

The echo at the end displays.

What's wrong?
<?
function conv_date($x) {
	if ($x != "" && substr($x,0,10) != "0000-00-00") {
		$fd = substr($x,5,2) . "/" . substr($x,8,2) . "/" . substr($x,0,4);
	} else {
		$fd = "";
	}		
	return $fd;
} 
// Set the variables for the database access:
$Host = "localhost";
$User = "adcd";
$Password = "1234";
$DBName = "adcd";
$Link = mysql_connect ($Host, $User, $Password);	
$today = mktime(0,0,0,date('m'), date('d'), date('Y'));
$tomorrow = $today + 86400;
$tom = getdate($tomorrow);
$emon = $tom["mon"];
if ($emon < 10){
	$emon = "0" . $emon;
}	
$eday = $tom["mday"];
if ($eday < 10) {
	$eday = "0" . $eday;
}	
$tomdt = $tom['year'] . "-" . $emon . "-" . $eday;
$qry = "SELECT * from schedule where date = '" . $tomdt . "'";
$res = mysql_db_query ($DBName, $qry, $Link);
$ns = mysql_num_rows ($res);
$ne = 0;
$subj = "Appointments Tomorrow with Lawn Sprinkler Services";
$header  = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: donotreply@LSS.com\r\n";	
$msg = "";
$mailto = "richard@rkassociates.com; aveatch@lawnsprinklerservices.com; lawnsprinklerservice@hotmail.com";
for ($i = 0; $i < $ns; $i++) {
	$sch = mysql_fetch_array($res);
	$qryc = "SELECT * from customer where ListID = '" . $sch['ListID'] . "'";
	$resc = mysql_db_query ($DBName, $qryc, $Link);
	$cust = mysql_fetch_array($resc);
	if ($cust['email'] != "") {
		$msg = $msg . "Dear " . $cust['contactname'] . ",<br><br>";
		$aptt = "";
		if ($sch['AMPM'] == "A") {
			$aptt = ", in the morning.";
		} else {
			if ($sch['AMPM'] == "P") { 
				$aptt = ", in the afternoon.";
			}
		}	
		$addr = "unknown";
		if (is_numeric(substr($cust['address1'],0,1))) {
			$addr = $cust['address1'];
		} else {
			if (is_numeric(substr($cust['address2'],0,1))) {		
				$addr = $cust['address2'];
			} else {
				if (is_numeric(substr($cust['address3'],0,1))) {		
					$addr = $cust['address3'];
				}
			}
		}
		$msg = $msg . "Lawn Sprinkler Services is scheduled to provide a service appointment to your location at " . $addr . " tomorrow, " . conv_date($sch['date']);		
		$msg = $msg . $aptt . "<br><br>";
		$msg = $msg . "If you need to cancel or reschedule this appointment, please call us at (316)-303-1200 today before 5:00 PM.<br><br>";
		$msg = $msg . "We look forward to providing you with service.<br><br>";		
		$msg = $msg . "Thank you,<br><br>";
		$msg = $msg . "Lawn Sprinkler Services<br><br>";	
		$ne++;
	}	
}	
$mres = mail($mailto, $subj, $msg, $header);	
echo $ne . " emails sent.";	
?>

Open in new window

0
Richard Korts
Asked:
Richard Korts
1 Solution
 
Mohamed AbowardaSoftware EngineerCommented:
Try sending email by simply using mail() function (no header) and see if it will be sent, if it's not work at all, you probably have misconfiguration in the server or the IP address is not static.
0
 
VampireofdarknessCommented:
If you echo $mres, what is the result? Have you changed servers or server config?

Also, this doesn't look, at a glance, to even attempt sending to customers.
0
 
haloexpertsexchangeCommented:
Does it work when you return the mailto back to just email?
I tried using the mail function with multiple addresses before and it did not work but with a single address it did.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
haloexpertsexchangeCommented:
sorry typoed my response if you set it back to just one email address.
0
 
Ray PaseurCommented:
$mailto variable on line 37.  Change those semi-colons to commas and tell us what happens then.
0
 
Richard KortsAuthor Commented:
Hi Ray,

I remembered that from before while I was out on errands. That fixes it.

Odd that php function mail can't recognize that. It changes them to semicolons when it actually sends the email.

I guess all php functions expect commas as delimiters or ???
0
 
Ray PaseurCommented:
Thanks for the points.  regarding this, "I guess all php functions expect commas as delimiters or ???" mostly that is true.  Best, ~Ray
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now