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>
Related
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.
For email activation I'm using php Sendmail code.
I'm not using any 'Smtp or Php mailer function' but using a 'variable'. Whenever I attach a subdomain name with my activation link it didn't work and no mail is send. But when i attach a domain name with my activation link it work and it send a mail. What may be the reason that subdomain name is not sending mail and same code but just changing subdomain name into domain name works fine and send mail. why?
This is my code :
$to=$email;
$subject="Your confirmation link here";
$header="from: Meet Your Love<your email>";
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://meetyourlove.2fh.co/confirmation.php?passkey=$confirm_code";
$sentmail = mail($to,$subject,$message,$header);
On third $message you can see my subdomain name from 2freewebhosting which is attach with confirmation.php which works for activating an email address but this subdomain link is not letting me to send an activation link in users email address. when i changed any domain name in it then it send mail what may be the reason??What is the best way to solve this problem? What should we exactly put a link which should be before /confirmation.php???
Please help me..!
try this code,
$from="katrinakaif#love.com";
$to ="yourmail#gmail.com";
$confirm_code="13";
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://meetyourlove.2fh.co/confirmation.php?passkey=$confirm_code";
$subject="test";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:'.$from . "\r\n";
mail($to, $subject, $message, $headers);
I have a form on my website which will send me an email using PHP. It will be sent to an email address from my hosting service, which I never check, so I set it up to forward emails sent to that address to my iCloud email address. This works great, since it preserves the "From" address so when I reply, it is sent to the person who filled out the form. The problem is, when I reply to the email sent from the form, the person who gets that reply will see it came from my iCloud account, and replies to that email will go directly to my iCloud account rather than to my hosting service email.
My question is, is there a way to specify in my PHP code what email should appear in the "From" field upon replying to the email (but of course, this is different from the "From" address in the first email sent to me (the person filling out the form)?
Essentially, I want it to work like this:
-Upon form submission, an email is sent to example#myhostingservice.com with the "From" address set to the email inputted in the form
-example#myhostingservice.com forwards the email to my iCloud account (but preserves the email address of person who filled out form in the "From" address)
-I reply to that email using my iCloud account, and the receiver sees it came from example#myhostingservice.com (not iCloud), and when they reply it goes to example#myhostingservice.com
Here is a snippet of my code to see what I'm working with:
$name = $_POST['name'];
$email_address = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
if( empty($errors))
{
$to = $myemail;
$email_subject = "$subject";
$email_body = "Name: $name \n \n $message";
$headers = "From: $email_address";
mail($to,$email_subject,$email_body,$headers);
}
Thanks!
From docs (http://php.net/manual/en/function.mail.php):
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
Although I must warn you, doing such may mark your email as spam since the email address it is being sent from does not match the From header.
I don't think this is possible using PHP - the email client you use on your iCloud account sets the new "Reply-To". However, try to add the hosting email account to your iCloud email client -(Using POP3 or IMAP)- then you will be able to "Send as" your hosting account and you won't need to forward everything to iCloud.
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);
?>
I have set automatically to send email to users from my website. but this email will place to spam of users with gmail accounts.However it is working fine with yahoo or hotmail accounts.
How should I solve this?
$to = "$Email";
$subject = "Greeting";
$message = 'message here';
$from = "sender#example.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: sender#example.com" . "\r\n" .
"Reply-To: sender#example.com" . "\r\n";
mail($to,$subject,$message,$headers);
Since your headers appear to be correct, it's probably keying on something within the message. One of the things that SpamAssassin (no idea if this is what Gmail uses) keys on is a very short message like the above containing a hyperlink or graphic, so you may benefit by actually making your message a little longer. One of the ways to find out is to send it to your own gmail account and when it appears in your spam folder, examine the headers there for any added spam information. It may contain clues as to what spam engine Gmail is using or what rules your message is breaking.
Please have a look here:
Spam sent to Contacts -
Message Delivery
Hope this helps!
it should be of smtp configuration email and site information email id should be diffrent.