Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication php mail

Tags:

php

I'm using mail to send e-mails from PHP. It's working fine, but now I need to use a more secure mail server.

I need to connect with the mail server using the following configuration:

smtp: "mail.newserver.com"
port: "25"
timeout: 60
auth: yes
user: name
pass: word

How should I change my code below so it works with above configuration?

$to = $SendTo;
$headers = "From: <info@---->" . "\r\n" . "X-Mailer: php";
$subject = "Website Contact : " . $uxGlobalLocation;
$body = $Bodycopy;

if (mail($to, $subject, $body, $headers)) {
    header ('Location: /index.php?option');
    exit();
} else {
    echo("<p>Message delivery failed...</p>");
}
like image 619
acctman Avatar asked May 04 '12 20:05

acctman


1 Answers

Actually mail function doesn't provide authentication functionality. Your have to use Mail class from Mail Pear package. See here for an example: http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm

like image 147
WojtekT Avatar answered Sep 20 '22 15:09

WojtekT