Help with sending link with email


#1

Hello, I could use some help with my submit.php file (below). This code is not something I created, but it woks successfully at sending the email, but the video link is still not arriving. The email message, that arrives successfully, shows, for example:
UploadForm-M:
Name: Chris-Test
E-Mail: chris8@…mail.com
Message: Test-Test
Video:

Any help/comments will be appreciated.

<?php

// if the url field is empty
//if(isset($_POST['url']) && $_POST['url'] == '')
{

	// put your email address here
	$youremail = 'wcform@real....com';

	// Important: if you added any form fields to the HTML, you will need to add them here also
	$body = "UploadForm-M:
	Name:  $_POST[name]
	E-Mail: $_POST[email]
	Message: $_POST[message]
	Video: $_POST[videolink]";

	if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) {
	  $headers = "From: $_POST[email]";
	} else {
	  $headers = "From: $youremail";
	}
	// finally, send the message
	mail($youremail, 'Contact Form', $body, $headers );
}

// otherwise, let the spammer think that they got their message through
// if no errors are set, continue
if(empty($error))
{
header('Location: http://real....com');
exit;
}
?>

#2

Why is the if statement commented out?

May be a style choice, but some changes,

$body = "UploadForm-M:
Name:  {$_POST['name']}
E-Mail: {$_POST['email']}
Message: {$_POST['message']}
Video: {$_POST['videolink']}";

Lastly, do you know that $_POST[‘videolink’] holds anything?


#3

Thank you for your reply. It now works successfully.
I’m now trying to have this code send the same identical email that goes to “$youremail”, to also go to the “E-Mail [email]” address. Any additional guidance with that, will be appreciated: Here’s the current code:

<?php
{
	$youremail = 'wcform@real....com';

	$body = "UploadForm-M:
	Name:  $_POST[name]
	E-Mail: $_POST[email]
	Message: $_POST[message]
	Video: $_POST[videolink]";

	if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) {
	  $headers = "From: $_POST[email]";
	} else {
	  $headers = "From: $youremail";
	}
	mail($youremail, 'Contact Form', $body, $headers );
}
if(empty($error))
{
header('Location: http://real...com');
exit;
}
?>

#4

So, what you want is to trigger an email to the person that sent it, and to a person that should receive it? Kind of like a receipt that you got it?


#5

thanks for your reply. yes kind of like a receipt


#6

So call mail twice. Once for the initial send, and then another time to show receipt. Though I would check to see if it was successfully sent when I do that.


#7

Thanks for your reply. Can you show me an example of “call mail twice”, please?
The reason I ask is I don’t know how to send the second mailing to the email address that comes from here:

$body = “UploadForm-M:
Name: $_POST[name]
E-Mail: $_POST[email]
Message: $_POST[message]”;

The email address that I want to send a second emailing to is: E-Mail: $_POST[email]

I tried this without success:

 '''''''''
    	$body = "E-Mail: $_POST[email]";
    	    $headers .= "Hello ".$_POST[name]." ;

    	mail($body, $headers );
    }

''''''''''

I look forward to some guidance. Much thanks


#8

https://www.w3schools.com/php/func_mail_mail.asp

You just need to call the function twice. Once to you, and again for the user that sent it.

// send the initial email
if(mail(...))
    // send the receipt
    mail(...)

#9

Yes, thank you for your reply and link, but I still don’t know how to take the email entered in the Form: E-Mail: $_POST[email] so it works in the mail(…) function,

any additional guidance will be appreciated


#10

Did you go to the link?

mail($_POST['email'], $_POST['email'], $_POST['email']);


#11

Thanks for the reply.

Yes, I went to the link (thanks for that), and tried the code below with limited success, which means an email arrived at this address: $youremail, but not at this address: $_POST[‘email’]

Any additional help will be welcomed.

<?php
{

	$youremail = 'wcform@real....com';

	// Important: if you added any form fields to the HTML, you will need to add them here also
	$body = "UploadForm-M:
	Name:  $_POST[name]
	E-Mail: $_POST[email]
	Message: $_POST[message]";

	$headers .= "Hello ".$_POST[name]."";
	mail($youremail, 'Real Message', $body, $headers );

	$body = "UploadForm-M:
	Name:  $_POST[name]
	E-Mail: $_POST[email]
	Message: $_POST[message]";

	$headers .= "Hello ".$_POST[name]."";
	mail($_POST['email'], 'test', $headers );
}

if(empty($error))
{
header('Location: http://real....com');
exit;
}
?>

#12

It may have… The mail function routinely ends up in the spam or junk folders, or is outright rejected by ISP’s.

I’m a fan of mailgun, but at onetime used PHPMailer.


#13

Thanks for all the help/replies. This code below works successfully, the only thing I can’t figure out is that when I open up the first email sent it shows that it was sent from: wcform@real…com, but the second email shows that it was sent from an email address pertaining to the server, how can I have the second email show it’s from wcform@real…com?
Here’s the current code:

<?php
{

	$youremail = 'wcform@real....com';

	$body = "UploadForm-M:
	Name:  $_POST[name]
	E-Mail: $_POST[email]
	Message: $_POST[message]";

	$headers .= "Hello ".$_POST[name]."";
	mail($youremail, 'Real Message', $body, $headers );

	$headers .= "Hello ".$_POST[name]."";
	mail($_POST['email'], 'test', $headers );
}

if(empty($error))
{
header('Location: http://real....com');
exit;
}
?>

#14

You would use the headers added to the function.


#15

Thanks again for your reply, but I’m not sure how to “use the headers added to the function”, can you provide some specificity?


#16

The link I posted mentions them…


#17

Got it, thanks again …