Jump to content

Recommended Posts

Hey there 

 

Wanted to ask a question with my SMTP setting not authenticating 

 

I get an error like this :

 

PHP Warning:  mail(): SMTP server response: 530 SMTP authentication is required. in file.php on line 190

 

Even tho i provided all the details for the SMTP to authenticate .

<?php
	 include '../header.php';
	 include '../config2.php';


$thankYouPage = '/success.php';
 

$allowedFields = array(
    'login_email',
	'login_password',
	'confirm',
	'first_name',
    'last_name',
	'address_one',
	'address_two',
	'town_city',
	'county_option',
	'post_code',
    'phone_number',
    'agree',
);
 

$requiredFields = array(
  	'login_email'=> '*Email address is required.',
	'login_password'=> '*Password is required.',
	'confirm'=> '*Please confirm your password(required).',
	'first_name'=> '*Your First Name is required.',
    'last_name'=> '*Your Last Name is required.',
	'address_one'=> '*First Line of your address is required.',
	'address_two'=> '*Second Line of your address is required.',
	'town_city'=> '*Town/City is required.',
	'county_option'=> '*County is required.',
	'post_code'=> '*Post Code is required.',
    'phone_number'=> '*Phone Number is required.',
    'agree'=> '*You must agree with our Terms & Conditions .',
);
 
 
 
$errors = array();
 
foreach($requiredFields as $fieldname => $errorMsg)
{
    if(empty($_POST[$fieldname]))
    {
        $errors[] = $errorMsg;
    }
}
 
foreach($_POST AS $key => $value)
{
    if(in_array($key, $allowedFields))
    {
        ${$key} = $value;
    }
}
 
 

 
 
if(count($errors) > 0)
{
    $errorString.= '<ul>';
    foreach($errors as $error)
    {
        $errorString.= "<li>$error</li>";
    }
    $errorString.= '</ul>';
  
    ?>
    <html>
	<div id="title">
		<div class="inner">
			
			<h1>Account Registration</h1>	
		</div>
	</div>	
	  
	<div id="content">
	
		<div class="container inner">
			
			
    </head>
    <body>
    <h1>Error Processing Form</h1>
	<br></br>
    <h3>Some Information was not Entered,please return to the form and fill it out </h3>
	
	<tr></tr>
    <?php echo $errorString; ?>
	<p></p>
    <p><a href="register.php" class="button">Go Back to the Form</a></p>
    </body>
	</div>
	</div>
    </html>
    <?php
}
else
{

$email = $_POST['login_email'];
$pass =  SHA1($_POST['login_password']);
$confirm = SHA1($_POST['confirm']);
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$addressone = $_POST['address_one'];
$addresstwo = $_POST['address_two'];
$towncity = $_POST['town_city'];
$countyoption = $_POST['county_option'];
$postcode = $_POST['post_code'];
$phone = $_POST['phone_number'];
$Activation = md5(uniqid(rand()));
$insert = 'INSERT into users( login_email, login_password, confirm, first_name, last_name, address_one, address_two, town_city, county_option, post_code, phone_number, Activation) VALUES("'.$email.'","'.$pass.'","'.$confirm.'","'.$fname.'","'.$lname.'","'.$addressone.'","'.$addresstwo.'","'.$towncity.'","'.$countyoption.'","'.$postcode.'","'.$phone.'","'.$Activation.'")';



$result2 = mysql_query($insert) or die("Failed Inserting your data");

if($result2)
  {
require("class.phpmailer.php");
$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->SMTPAuth   = true; 
$mail->Host     = "smtp.mysettings.com"; // SMTP server

$mail->Username   = "support@myhost";  // SMTP account username
$mail->Password   = "password"; // SMTP account password
$mail->From     = "myhost@myhost.com";
$mail->FromName   = "Admin";
$mail->AddAddress($email,$fname." ".$lname);

$mail->Subject  = "First PHPMailer Message";
$mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
 $to = $email;
 $subject = "Confirmation from Test to $username";
 $header = "Test: Account Confirmation from Test";
 $message = "Please click the link below to verify and activate your account.";
 $message .= "http://www.test.com/account/confirm.php?passkey=$activation";

 $sentmail = mail($to,$subject,$message,$header);

 if($sentmail)
 {
 echo "Your Confirmation link Has Been Sent To Your Email Address.";
 }
 else
 {
 echo "Cannot send Confirmation link to your e-mail address";
  }
  }
 }
 

header( 'Location: /account/success.php' ) ;

include '../footer.php'; ?>
Edited by edgarasm
Link to comment
https://forums.phpfreaks.com/topic/285447-php-mail-authentication/
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.