Jump to content

php sending emails....

jameshumphries47

im trying to send an email form my site using this code, its hosted on hostinger.

but the email will not send

            <?php            $subject = "Your account has been added!";            $body = "Hi";                    $reciver = "------------.--------@btinternet.com";            sendmail($receiver, $subject, $body);            function sendmail($receiver,$subject,$body){                $headers = 'From: ' . "nikki@---------.co.uk\r\n".                   'Reply-To: ' . "nikki@---------.co.uk\r\n" .                   'X-Mailer: PHP/' . phpversion();                   mail($receiver, $subject, $body, $headers);            }            ?>

any ideas

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

Take a look at the third line.

  <?php            $subject = "Your account has been added!";            $hello";                    $reciver = "------------.--------@btinternet.com";            sendmail($receiver, $subject, $body);            function sendmail($receiver,$subject,$body){                $headers = 'From: ' . "nikki@---------.co.uk\r\n".                   'Reply-To: ' . "nikki@---------.co.uk\r\n" .                   'X-Mailer: PHP/' . phpversion();                   mail($receiver, $subject, $body, $headers);            }            ?>
Link to comment
Share on other sites

Link to post
Share on other sites

Take a look at the third line.

i copied that wrong sorry its meant to say 

          <?php            $subject = "Your account has been added!";            $body = "Hi";                    $reciver = "--------------@btinternet.com";            sendmail($receiver, $subject, $body);            function sendmail($receiver,$subject,$body){                $headers = 'From: ' . "nikki@--------------\r\n".                   'Reply-To: ' . "nikki@---------------\r\n" .                   'X-Mailer: PHP/' . phpversion();                   mail($receiver, $subject, $body, $headers);            }            ?>

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

No programmer but maybe this: $reciver = "--------------@btinternet.com";

 

receiver is spellt wrong.

 

 

---

<-----><-----><-----><-----><-----><-----><-----><-----><-----><----->

                                         Cold

Link to comment
Share on other sites

Link to post
Share on other sites

I would suggest against using the PHP mail function, try using something like Pear Mail instead. Here's code that I use to send mail on one of my sites.

function sendMail($fullName, $emailAddress, $subject, $body) {	require_once "Mail.php";	$from = "**** <*************@****************.***>";	$to = "$fullName <$emailAddress>";	$subject .= "\r\n\r\n";	$host = "**********.***";	$port = "***";	$username = "******************";	$password = "******************";	$headers = array('From' => $from,		'To' => $to,		'Subject' => $subject);	$smtp = Mail::factory('smtp',		array('host' => $host,			'port' => $port,			'auth' => true,			'username' => $username,			'password' => $password));	$mail = $smtp->send($to, $headers, $body);	if (PEAR::isError($mail)) {		echo("<p>" . $mail->getMessage() . "</p>");	} else {		echo("<p>Message successfully sent!</p>");	}}

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

IIRC PHP's built in mail function is buns, and it requires different libraries and configuration in order to send out mail from an SMTP server and such.

Link to comment
Share on other sites

Link to post
Share on other sites

IIRC PHP's built in mail function is buns, and it requires different libraries and configuration in order to send out mail from an SMTP server and such.

 

The configuration of an SMTP server in php.ini is only required on Windows; However, you do need sendmail installed to send mail using PHP on Linux. 

Link to comment
Share on other sites

Link to post
Share on other sites

I would suggest against using the PHP mail function, try using something like Pear Mail instead. Here's code that I use to send mail on one of my sites.

 

function sendMail($fullName, $emailAddress, $subject, $body) {	require_once "Mail.php";	$from = "**** <*************@****************.***>";	$to = "$fullName <$emailAddress>";	$subject .= "\r\n\r\n";	$host = "**********.***";	$port = "***";	$username = "******************";	$password = "******************";	$headers = array('From' => $from,		'To' => $to,		'Subject' => $subject);	$smtp = Mail::factory('smtp',		array('host' => $host,			'port' => $port,			'auth' => true,			'username' => $username,			'password' => $password));	$mail = $smtp->send($to, $headers, $body);	if (PEAR::isError($mail)) {		echo("<p>" . $mail->getMessage() . "</p>");	} else {		echo("<p>Message successfully sent!</p>");	}}

I have no idea how this stuff works once it's online, but isn't kind of bad to put username and password for an email service in the code?

 

Or is this code somehow hidden and "just works"? Kind of like an .exe is compiled and not actually showing its code?

 

If yes, how does that work? Wouldn't it still be feasible to get that info or is it purely server side stuff and you make a form for the user (with whatever they are contacting you about etc) that sends these details to this function (on the server) without it ever being processed on the client browser?

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to comment
Share on other sites

Link to post
Share on other sites

I have no idea how this stuff works once it's online, but isn't kind of bad to put username and password for an email service in the code?

 

Or is this code somehow hidden and "just works"? Kind of like an .exe is compiled and not actually showing its code?

 

If yes, how does that work? Wouldn't it still be feasible to get that info or is it purely server side stuff and you make a form for the user (with whatever they are contacting you about etc) that sends these details to this function (on the server) without it ever being processed on the client browser?

Php is compiled serverside and executed, so no the client never sees the source code. So theoretically you are fine having passwords and such like that, just make sure its not uploded as something that wont be compiled by the server like a text file or something, oh and don't put it up on github.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×