Jump to content

PHP function to send email to manual email entry


slawotrend

Recommended Posts

Because you are not following directions and not RTFM.

  $to_email1          = trim(strip_tags($_POST['sup1'])); // supplier email on the form
    $to_email2         .= ','.trim(strip_tags($_POST['sup2']));
    $to_email3         .= ','.trim(strip_tags($_POST['sup3']));
    $to_email4         .= ','.trim(strip_tags($_POST['sup4']));

Why are you setting different variables? I said to use one. The concatenation does nothing when used with a new variable. This is what you should use:

  $to_email1          = trim(strip_tags($_POST['sup1'])); // supplier email on the form
    $to_email1         .= ','.trim(strip_tags($_POST['sup2']));
    $to_email1         .= ','.trim(strip_tags($_POST['sup3']));
    $to_email1         .= ','.trim(strip_tags($_POST['sup4']));

Then:

$mailer = mail($to_email1,  $email_subject, $email_message, $headers);

Had you read the documentation you would have seen that 'mail' only takes 4 arguments. Also you did not remove the error suppression (@) as suggested by ginerjm so you are not able to see any error messages which would also have helped you figure out what is wrong.

Link to comment
Share on other sites

I tried to change to this before and it didn't work,

  $to_email          = trim(strip_tags($_POST['sup1'])); // supplier email on the form
    $to_email         .= ','.trim(strip_tags($_POST['sup2']));
    $to_email         .= ','.trim(strip_tags($_POST['sup3']));
    $to_email         .= ','.trim(strip_tags($_POST['sup4']));

Then:

$mailer = mail($to_email,  $email_subject, $email_message, $headers);

The code always sents one email intead of 4. Weird.

Would there be possible to use array for POST and then enforce to use array in mailer? Maybe this would work.

 

Thanks for help anyway.

 

 

Link to comment
Share on other sites

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.