Jump to content

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 .= "me@email.com";

	$headers["From"] = "Me <me@email.com>";
	$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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.