Jump to content

Whats wrong with my mail script?


matt.sisto

Recommended Posts

I have been trying to figure it out but I can't, any help appreciated.  8)

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id1'";
  $result=mysql_query($sql);
  $to = mysql_result($result, 0, 0);


  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";
  $result=mysql_query($sql);
  $to.= mysql_result($result, 0, 0);

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";
  $result=mysql_query($sql);
  $to.= mysql_result($result, 0, 0);


  $sender = '[email protected]';
  $headers = "SRC: Administrative Team";
  $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team.";
  $message.= "<br /> Event date:  ".$event_start."\n";
  $message.= "<br /> Event end date: ".$end_date."\n";
  $message.= "<br /> Service: ".$service."\n";
  $message.= "<br /> Start time: ".$start_time."\n";
  $message.= "<br /> Address: ".$address_first_line."\n";
  $message.= "<br /> Post Code: ".$post_code."\n";

mail($to, $sender, $message, $headers);

Thanks and regs.

Link to comment
https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/
Share on other sites

Look carefully at what you're telling your program to do:

<?php

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id1'";

  $result=mysql_query($sql);

  $to = mysql_result($result, 0, 0);

  // $to = '[email protected]';

 

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";

  $result=mysql_query($sql);

  $to.= mysql_result($result, 0, 0);

  // $to = $to . '[email protected]'

  // ==> $to = '[email protected]' . '[email protected]'

  // ==> $to = '[email protected]@foobar.com'

 

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";

  $result=mysql_query($sql);

  $to.= mysql_result($result, 0, 0);

  // $to = $to . '[email protected]'

  // ==> $to = '[email protected]@foobar.com' . '[email protected]'

  // ==> $to = '[email protected]@[email protected]'

 

 

  $sender = '[email protected]';

  $headers = "SRC: Administrative Team";

  $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team.";

  $message.= "<br /> Event date:  ".$event_start."\n";

  $message.= "<br /> Event end date: ".$end_date."\n";

  $message.= "<br /> Service: ".$service."\n";

  $message.= "<br /> Start time: ".$start_time."\n";

  $message.= "<br /> Address: ".$address_first_line."\n";

  $message.= "<br /> Post Code: ".$post_code."\n";

 

// $to contains: '[email protected]@[email protected]'

// Does $to look like a valid email address to you?

mail($to, $sender, $message, $headers);

?>

Change all instances of:

$to.= mysql_result($result, 0, 0);

 

to:

 

$to.= ', ' . mysql_result($result, 0, 0);

 

You should only make two changes based on the code you presented, i.e. you don't change the line: $to = mysql_...

 

Also it's really better if you throw just one query at the database rather than three, but you can work on that after you have the initial approach working.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.