Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

how to send mail in php with $mailto

Featured Replies

I am working on a form and it is working well, but when try to add the following line:

$mailto .= .$sub_email. ;

it is not working right because what I am trying to do is for the person who had submitted the form to get a copy of their submittion.

Advance thanks.

I am using php code as follows:

<?php

$mailto = '[email protected]' . ', ' ;

$mailto .= .$sub_email. ;

$subject="E-mail Page";

$formurl="formula.php";

$errorurl="mailerror.php";

$thankyouurl="ThankYou.php";

$YES = $_POST[YES];

$Name = $_POST[Name];

$sub_email = $_POST[sub_email];

$Phone = $_POST[Phone];

$Mailing_address = $_POST[mailing_address];

$City = $_POST[City];

$State = $_POST[state];

$Zip_Code = $_POST[Zip_Code];

$messagetext = 'Email Testing';

mail($mailto, $subject, $messagetext, "From: "$Name"

<$email>nReply-To: "$sub_email"

<$email>nXMailer: chfeedback.php 2.01");

header("Location: $thankyouurl");

exit;

?>

php2005,

As far as I know, the line should read

$mailto .= $sub_email;

enclosing the variable name in the '.' concatenation operator appears to be incorrect.

Later in the code, the indexes into the $_POST array are not enclosed in quotes. This would be correct if those are constants, but...

Regards, Don

  • Author

Don,

Thank you for the help.

It did work but for some reason the e-mail only comes to me if I use the in house e-mail account.

For example in my web form I type [email protected] at the field $sub_email I do not get any e-mail at my yahoo account, but if in case I type the inhouse e-mail account at $sub_email it will show at my e-mail account. Do you have any idea what can be the problem?

thank you

php2005,

So, if you enter a your inhouse email at $sub_email so that $mailto becomes

[email protected], [email protected]

you will receive two emails. If you only receive one, then the problem is with concatenating the second address; but if you provide values so that $mailto becomes

[email protected], [email protected]

you only receive mail at scm1m2m3?

I'm not sure what could be going on here. These are some thoughts:

Are you certain the 2nd address is working and is correct. Try a 3rd address.

If you put the second address in $mailto all by itself does it work?

What happens if you assign values so that $mailto becomes

[email protected], [email protected]

?

regards, Don

  • Author

I did try to use an hotmail, gmail, or yahoo e-mail account and none of them went to my account.

I did try also to use $mailto='[email protected]' and did not work.

I tried also but didn't work.

$foo='[email protected]';

$mailto=$foo;

any idea?

  • Author

I also tried to use

$mailto ="inhouse email account".','.$sub_email;

but only went to the inhouse e-mail account and not to the yahoo account

Assuming you DO get two message in the last example,

it sounds a bit like there is some problem sending mail to domains other than your inhouse domain. This is not an area I'm knowledgeable in. Do you have an inhouse IT department that manages your servers? They may be able to explain why you can send to your local domain and not an external domain.

Regards, Don

  • Author

I only get one message

well, i guess the one message thing is no problem. I tested here and get the same result to a dup address.

I'm thinking its a problem with the server being able to handle external email addresses.

Sorry I couldn't be more help

Regards, Don

  • Author

Don,

Thank you so much for your help.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.