Alanistic Posted September 24, 2008 Share Posted September 24, 2008 Hi All, I have a small question. Just now I'm slowly teaching myself PHP and I'm playing about with SMTP messages. My webhosting comes with an SMTP server, however this requires authentication. I receive the following error when using a simple piece of code to send a message: Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\feedback.php on line 10 The code I use is: <?php error_reporting(E_ALL); ini_set('display_errors', TRUE); $recipient = '[email protected]'; $subject = 'Mail Test'; $message = 'Greetings,' ."\r\n\r\n\t".'This is a test of mail functionality.' ."\r\n\r\n".'Thanks'; $headers = 'From: [email protected]"\r\n" .'Reply-To: [email protected]'."\r\n"; if (mail($recipient, $subject, $message, $headers)) { echo 'Mail Sent'; } else { echo 'Mail NOT Sent'; } ?> When I add the authentication details however in the code below it works: $smtpinfo["host"] = "auth.smtp.1and1.co.uk"; $smtpinfo["port"] = "25"; $smtpinfo["auth"] = true; $smtpinfo["username"] = "email"; $smtpinfo["password"] = "password"; My question is: how do you deal with messages without exposing your password in the code? Is there a more secure way to code messages if the server needs authentication? Link to comment https://forums.phpfreaks.com/topic/125686-smtp-authentication/ Share on other sites More sharing options...
monkeytooth Posted September 24, 2008 Share Posted September 24, 2008 Well i havent played with the Secure mailing concept yet of the mail() function.. but generally it looks the same minus the extra smtpinfo.. So that said, short of it actually mailing your password with the email being sent in the headers or otherwise, your password is generally fine or should be.. one way or the other your going to have to embed that password somewhere for the SMTP to work.. beauty about PHP though is the code is hidden from HTML output.. so its not gonna display that way either.. I dunno just food for thought.. but in the name of "Safety" use an uncommon password.. something thats not common to account access you have anywhere.. Link to comment https://forums.phpfreaks.com/topic/125686-smtp-authentication/#findComment-649905 Share on other sites More sharing options...
Alanistic Posted September 25, 2008 Author Share Posted September 25, 2008 Thanks for the info monkey tooth, much appreciated. Link to comment https://forums.phpfreaks.com/topic/125686-smtp-authentication/#findComment-650658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.