Jump to content

[SOLVED] define()


sawade

Recommended Posts

bool define ( string $name , mixed $value )

 

Is it possible to put SMTP values into an external php file and call on them?

 

For example:

 

<?php
  // Define Email constants
  define('STMP_HOST', 'localhost');
  define('STMP_PORT', '26');
  define('STMP_PASSWORD', 'password');
  define('STMP_USERNAME', 'username');
?>

 

<?php
/* Email */
require_once "Mail.php";
    require_once "emailcontants.php";

	$to = $_POST['email'] . ', ' ;
	$to .= "[email protected]";

	$headers["From"] = "Me <[email protected]>";
	$headers["Subject"] = "Email";

	$smtp["host"] = STMP_HOST;
	$smtp["port"] = STMP_PORT;
	$smtp["auth"] = true;
	$smtp["username"] = STMP_USERNAME;
	$smtp["password"] = STMP_PASSWORD;

	$msg = "Hello!";

	$msg = wordwrap($msg, 70);

	/* Sends Email */
	$mail = Mail::factory('smtp', $smtp);

	$mail->send($to, $headers, $msg)
		or die('Error accessing SMTP server.');
?>

Link to comment
https://forums.phpfreaks.com/topic/171645-solved-define/
Share on other sites

Well I've never used define() and the only time I have practiced with it is for mysql connect constants.  Wasnt' sure if it was only useable with mysql.  And no I haven't tried it yet.  I am working on another aspect of the code first before jumping headfirst into this.

Link to comment
https://forums.phpfreaks.com/topic/171645-solved-define/#findComment-905091
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.