Any idea why the [Enter email] field on this form will only reach me#me.com if the email entered matches me#me.com?
If I put in any other email address than the one listed in $to=, the email doesn't send.
$fieldname = 'images';
if ($_POST){
// we'll begin by assigning the To address and message subject
$to="me#me.com";
$subject="Registration";
$from = "<".stripslashes($_POST['email']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// now we'll build the message headers
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"\n";
Here's a Pastebin.
You are setting the from header to be the address posted in the form, and the to header to be your email address. Should be reversed if you are trying to send an email to them.
$to="me#me.com";
$subject="Registration";
$from = "<".stripslashes($_POST['email']).">";
If indeed you want the email to appear to come from the address listed in the form, you can't in general do that. You can't send email on behalf of another use (your SMTP server is likely to reject it these days). This is to prevent pfishing attacks (FROM: Someone#ThatYouKnow.com, SUBJECT: What is that password again?).
Send it from an email address that you control. Include the email address from the form as part of the body of the email.
Related
I'm trying to figure out how to send website visitor message to administrator from "send message" form on page.
For example in verification scenario user receives confirmation message from my web mail:
$headers .= 'From: <adminemail#email.com>' . "\r\n";
to his email:
$to = 'useremail#email.com';
I'm not sure, how to send and receive visitor message:
$to = 'adminemail#email.com';
from:
$headers .= 'From: <adminemail#email.com>' . "\r\n";
via admin email to admin email and receiving visitor email for further answer just as message $mail together with $message, or I could use visitor email as sender:
$to = 'adminemail#email.com';
from:
$headers .= 'From: <visitormail#email.com>' . "\r\n";
Any guide or advise would be useful
You shouldn't set the From email to the visitors email, as this will get your server flagged from sending spam (since the email isn't really from the visitor).
Instead, you should set the From email to one on your domain (ex. form#domain.com) and set the Reply-To to the visitors email. This way, when you reply to the email it will go to the visitor correctly.
For example:
From: <form#mydomain.com>
Reply-To: <visitormail#email.com>
To: My Name <adminemail#email.com>
While sending an e-mail using php mail() function, the 'From' header can get any random e-mail address and/or name we desire.
However, the 'Reply-To' header seems to receive only the accurate e-mail address, apparently in order let the receiver reply to a valid address.
I was wondering if there is any possible way to show a random email address on the 'Reply-To' header, while making reply email to send to a different one.
Is that possible at all?
Suppose this is our code:
$subject = "Your subject";
$message = "$message";
$headers = 'From: myemail#my_domain.com' . "\r\n" .
'Reply-To: ' . $email;
Here we can clearly see that the From address is different than reply to address, this is what tells the browser from which address has the mail been sent and where to reply to, but you want to mask the address of reply-to... So tell me this, if we mask the reply-to address to another address, then what will happen?
The browser will try to reply to the masked address not the real one... So I believe it is not possible to mask the reply-to address... Because the masked address is not ours, and thus we won't get any reply at all..
I have a contact form where you specify the contact Information along with your email id. Once the form is sent it comes to my Inbox. The mail specifies the Information supplied by the user. I would like the sender of the contact form to receive a read receipt once I open the email.
This is what I have done so far
$name=$_POST['name'];
$email_address = $_POST['email'];
$subject='Contact Form Replies';
$phone=$_POST['phone'];
$message=$_POST['msg'];
$body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email_address\n Phone Number: $phone \n Message: $message \n ";
$headers = 'From: ' .$email_address. ''.
$headers .= 'X-Confirm-Reading-To: '.$email_address. '';
mail('xyz#gmail.com', $subject, $body,$headers))
?>
Now as per this code the mail gets successfully delivered to my Inbox. But once I open the mail, the read receipt does not go to the sender. Kindly advice on how I can overcome this Issue
Most email (web) clients disable any ability for the sender to check if an email is opened. They disable JavaScript, disable external sources so this is only possible with a own email server where users all use the same software such as outlook to have a reliable result.
However one possible way is to add an HTML image linking to image.php?receit=1234 and let that load up a php script that returns a tracking pixel. Now you know the email is opened and the user clicked the button to show all images.
I am using the following code along with HTML for header .
$email="example#example.com"; in the example and I want to implement variable in its place.
Code as posted below but its not showing error nor sending email.
I have tried the following links PHP email form not sending information , PHP Sending Emails with File Attachments - Email Not Sending At All .
I have tried
$headers .= "From: <".$email.">\n";
and
$headers .= $email;
This displays $email in the label from header in email.
But its working fine till this line:
$headers .= 'From: ' .$email. "\r\n";
This above line is not sending email if I remove this line it works but it does not add From email id to the header.
Please help me out it does not show any error and I have tried many variations to the above code but still stumped.
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['contact'];
$subject = "feedback";
$question = $_REQUEST['question'];
$body = "<html>
<head>
</html>";
$mime_boundary = "<<<--==+X[".md5(time())."]\r\n\r\n";
$headers = "MIME-Version: 1.0"."\r\n" ."Content-Type:text/html;"."\r\n";
$headers .= 'From:'.$email. "\r\n";
$to ='example#example.com';
mail($to,$subject,$body,$headers);
echo "<script>alert(' message sent.');</script>";
?>
I had the same issue with one of the servers I were dealing with. Apparently in my server, not specifying "From" header sends email from the default mail address of your account (in case of a shared hosting). I chose this solution as an ad-hoc fix and specified my actual from address in "Reply-To" header. This way, I can still receive the replies sent to those email threads.
This method seems feasible for just functional email addresses (eg., support#example.com)only. If you are using this approach for a user's email address (eg., john#example.com), chances are that the recipient might think of your email as a spam.
if you use standard mail function, then try this(do not add "From" header to $headers):
mail($to,$subject,$message,$headers,"-f ".$email);
On my website I have a contact form, where the user can report bugs or submit feature requests. The form contains a subject and message.
I want the form to email me directly, either with PHPMailer or with PHP's built-in mail function.
The issue here is when generating the email, the sender has to be an address I own, not the actual user's email address. The reason for this is obvious, since we shouldn't be allowed to impersonate other people. However I want to be able to email my users back directly from my inbox, which I can't do since I can't use their address to email myself in the script.
What is the best way to construct the contact form then?
The only workaround I can think of is to insert the message + sender address into a database, and then read it manually from there....an epic hassle.
I would be grateful for any suggestions.
Set the Reply-To e-mail header, so you'll get something like this:
<?php
$headers = 'From: you#example.com' . "\r\n";
// Set the sender address as Reply-to below
$headers .= 'Reply-To: sender#example.com' . "\r\n";
mail('you#example.com', 'Subject here', 'The message goes here', $headers);
?>
This way you will be the sender, but when you hit the reply button in your mail client, it will default to reply to the address listed in the Reply-To header.
Why does the center have to be an address you own?
SMTP won't prohibit you from providing the email your user provides as the sender. As long as the SMTP server allows you to relay from it, it will take any value for sender and recipient.
Another option would be to make a sender email up (contact-form#yourdomain.com) and set the Reply-To field to your user's email address.
You can use the code below to receive an email from an address you own but when you reply it'll go to the user's email
<?php
$to = 'youremail#yourdomain.com';
$subject = 'the subject';
$message = 'message';
$headers = 'From: youremail#yourdomain.com' . "\r\n" .
'Reply-To: user#useremail.com' . "\r\n" .
mail($to, $subject, $message, $headers);
?>