Get Domain for an Unfinished Website

0

Well folks, I'm building a website and I needed to get a domain to handle the contacts page, rather the emails.

The problem is this: I am using phpmailer and I want the user to be able to communicate with the "owner" of the website, ie, any email [email protected] would receive / manage all emails from users.

However using gmail SMTP (the only one I found "free") gives me a lot of errors that I think are permissions.

I have tried the "Postmarapp", but the problem is that they ask for domain of the website, something that I do not yet have, because, the same is still under construction.

So I wanted to know if it's possible to get that domain before it's done.

I also leave here the code (form HTML and php) that I have used. (P.S: gmail SMTP)

 <form class="form-horizontal" role="form" method="post">
        <div class="form-group">
            <label for="inputname3" class="col-sm-2 control-label">Nome</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="inputname3" placeholder="Nome" name="sendName">
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
            <div class="col-sm-10">
                <input type="email" class="form-control" id="inputEmail3" placeholder="Email" name="sendEmail">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPass3" class="col-sm-2 control-label">Password</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" id="inputPass3" placeholder="Password Email" name="sendPass">
            </div>
        </div>
        <div class="form-group">
            <label for="inputAssunto3" class="col-sm-2 control-label">Assunto</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="inputAssunto3" placeholder="Assunto" name="sendSubject">
            </div>
        </div>
        <div class="form-group">
            <label for="inputMessage3" class="col-sm-2 control-label">Mensagem</label>
            <div class="col-sm-10">
                <textarea placeholder="Escreva aqui a sua mensagem*" id="inputMessage3" name="sendMessage"></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default" name="send">Enviar</button>
            </div>
        </div>
    </form>


$name = $_POST['sendName'];
$email = $_POST['sendEmail'];
$subject = $_POST['sendSubject'];
$message = $_POST['sendMessage'];
$password = $_POST['sendPass'];

require_once('phpmailer/class.phpmailer.php');
require_once('phpmailer/PHPMailerAutoload.php');
require_once('phpmailer/class.smtp.php');

define('GUSER', $email);
define('GPWD', $password);

$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
//$mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$mail->CharSet = 'UTF-8';
$mail->Host = 'smtp.gmail.com';'smtp.live.com';
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->From = $email;
$mail->msgHTML($message);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->SetFrom($email,$name);
$mail->AddAddress("[email protected]","Joao");
$mail->AddReplyTo($email,$name);

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
    
asked by anonymous 14.09.2016 / 03:50

1 answer

0

To use smtp of Gmail using PHPMailer, the procedure occurs in two ways:

  • first: less secure (used on localhost during development or on uncertified domains): "Enable access to less secure apps" in your goolgle account you should go to settings page = > go to the security guide and on Disable access to less secure apps enable access. The short path via browser would be (being logged into your account) " link " and enable access.
  • Second: more secure and recommended: use a domain with SSL / TLS. Note that Gmail uses port 465 for connections with SSL certificates and 587 for TLS certificates if you do not use a certified connection you must use aspmx.l.google.com on port 25 plus this restricts the sending just for Gmail emails.

I use good for development in localhost PHPMailer works quietly even with a self-signed certificate, as its case (it seems to me) already have a domain (?) because it wants to send emails from the contact page, I recommend this link for take a look .

If you do not want to follow either the first or the second option described, another path is possible.

For this you will need to create an application to use authentication (XOAUTH2) and in your PHPMailer configuration add the authentication key.

A basic step-by-step provided by the PHPMailer repository itself:

link

And of course take a look at your PHPMAiler's examples folder on how to use google or xoauth:

link

If you have errors, please return the description.

    
14.09.2016 / 15:38