Send Mail Script

james3uk

New Member
Messages
14
Reaction score
0
Points
0
Hi. I've got a php send mail script to allow visitors of my website to tell their friends about the site.

This is it:

<?php
$email = $HTTP_POST_VARS['email'];
$subject = 'A friend has recommended friendbot.co.uk to you!';
$message = $HTTP_POST_VARS['message'];
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you. Your email has been sent.</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>

It sends the messages fine, however when it is recieved, the sender email address is CPANELUSER@skyy.x10hosting.com. I was wondering if there is any php code that I could add to the script to change this.

Any suggestions welcome.
Thanks.

James :)
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Also, your pattern should have ^ at its start and $ at its end. Otherwise it'll match any string which *contains* an email address.
 

tittat

Active Member
Messages
2,478
Reaction score
1
Points
38
By default PHP mail is send as user [at] servername.
thats why the reason when using mail() function,the mail goes to spam or junk.
 
Last edited:
Top