Mail Function:

Status
Not open for further replies.

zubair12

Banned
Messages
631
Reaction score
0
Points
0
I am using a contact for which use mail() function to send mail of user comments to my email address..
I try to add one more mail function in it to send mail to user who is sending comments to me but i am fail....

Code:
$to      = "name@example.com";

                      $subject = 'Hi';
$msg     = "From : $name \r\ne-Mail : $email \r\n" . "Message : $message";

mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");

where name@example.com is my email. and $email is user email...
I want to send some message to user also when he send me comments..
 

pythondev

New Member
Messages
59
Reaction score
0
Points
0
do you want to send mail from the script like an auto rsponder or you trying to inject the user into the from address of the email?
PHP:
<?php
$to      = "name@example.com";
$subject = 'Hi';
$msg     = "From : $name \r\ne-Mail : $email \r\n" . "Message : $message";
$headers = "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"

if (mail($to, $subject, $msg, $headers)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>
 

pythondev

New Member
Messages
59
Reaction score
0
Points
0
ohh on that case... pretty simple..

PHP:
<?php
$to      = "name@example.com";
$subject = 'Hi';
$subject2 = "Thanks for your comment";
$msg     = "From : ".$name."\r\ne-Mail : ".$email."\r\nMessage : ".$message;
$msg_reply = "Hello ".$email."\n\n Thanks for posting your comment to my board \n looking forward to hearing from you again";
$headers = "From: ".$email."\r\nReply-To: ".$email."\r\nReturn-Path: ".$email."\r\n";
$headers2 = "From: ".$to."\r\nReply-To: ".$to."\r\nReturn-Path: ".$to."\r\n";

$msg_me = mail($to, $subject, $msg, $headers);
$msg_you = mail($email, $subject2, $msg_reply, $headers2);

if (!$msg_me) {
  echo("<p>Message delivery to Site Owner failed...</p>");
 } elseif(!$msg_you) {
  echo("<p>Message delivery to user failed...</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
}
?>
 
Last edited:

zubair12

Banned
Messages
631
Reaction score
0
Points
0
thanks for that....one more problem is occuring i am using google apps...

it is working correctly.when i use my email in mail function it do not send email to google apps email. but from hotmail it is receiving mail
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Does the email address exist at google apps? Only the user you created has an address. The hotmail email may be a backup if the user doesn't exist.

check here: https://www.google.com/a/cpanel/{your domain goes here}/EmailAddresses
 

zubair12

Banned
Messages
631
Reaction score
0
Points
0
yes email address exist and it receive emails from hotmail but not from the php contact form
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
I can see no reason why it wouldn't work then. Unless your email address has weird characters PHP is interpreting wrong or you spelled something wrong, you probably have to talk to google apps support.
 

pythondev

New Member
Messages
59
Reaction score
0
Points
0
if it does have strange charachters in the email, it will probably insert slashes,
you could try using
$email = stripslashes($email);

before the form to see if that helps.
 
Status
Not open for further replies.
Top