Get Dominio for an unfinished website

Asked

Viewed 62 times

0

Good people, I’m building a website and I needed to get a domain address for the contact page, more like 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, for example, an email any [email protected] would receive/manage all emails coming from users.

However when using gmail SMTP (the only one I found "free"), it gives me an enormity of errors that I think are by permissions.

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

So I was wondering if it’s possible to get that domain before I’m done.

I also leave here the code (HTML and php form) 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";
}
  • 1

    It doesn’t seem to make any sense. Post the errors you receive when you try to send email via gmail smtp. Usually for sending email there is no need for a domain.

  • If using gmail smtp is not necessary but if using the postmarkapp is necessary

  • but they are different things... Postmark is an api (outsourced webservice) and must follow the rules of use of the api.. After all, you want to use the api or a library like phmailer, swiftmailer, etc?

  • I when I get home put the errors that appear to me using gmail smtp

  • @Danielomine this here the mistakes that appear to me when for example I want the "From" to be from a Hotmail for example :

  • 2016-09-14 19:42:16 CLIENT -> SERVER: EHLO localhost 2016-09-14 19:42:16 CLIENT -> SERVER: AUTH LOGIN 2016-09-14 19:42:17 CLIENT -> SERVER: Ywryawfuby5ylniuzi5tqghvdg1hawwuy29t 2016-09-14 19:42:17 CLIENT -> SERVER: aWJyYXRvcnJlczEw 2016-09-14 19:42:17 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/? p=badcredentials va3sm5661174wjb.18 - gsmtp 2016-09-14 19:42:17 SMTP Error: Could not authenticate. 2016-09-14 19:42:17 CLIENT -> SERVER: QUIT 2016-09-14 19:42:17 SMTP connect() failed.

  • It is not allowed to set a From different from the email used in authentication. Currently virtually all email services block. In the directive From, put the same email you’re using for authentication and then you’ll see that it works.

  • But I am passing the same email in From, IE, the user has the contact form where you enter your name your email the pass of your email and the message and then sends to another email that I created that rwcebera will make the management of all emails of the site recwbera all emails

  • but then it’s even worse.. rsrsrs.. if the user inserts email that isn’t from gmail, gmail won’t authenticate.. In fact, this error message you posted is saying this very clearly, that it does not accept this user and password.. Gmail SMTP is not a webservice where you can insert any email to authenticate.. To authenticate you need to set up a @gmail.com account. And "From" as I mentioned, needs to match the email used for authentication.

  • Is there any way to overcome this problem? And I need it to work for all emails....

  • Simply set up a gmail account for authentication, as I have repeatedly commented in the comments above. http://answall.com/search?q=gmail+phpmailer

  • Okay thanks I’ll try later say something thanks for the help

  • The problem is that it is using user data (email | password) to use in your Phpmailer. This will never work you have to use your Gmail credentials to do this. As I explained in my reply you have to use your Gmail credentials (email | password) so that the information entered by the user is sent to you.The !!!

  • Okay this I’ve tried and it works as I had explained in the post above, however , then when receiving the email and as if it had sent from me to me because the from gets the same email that rwcebeu.... The only solution would be to pass the "Sender" email on the subject not???? Or there is another solution?

  • ok as I said earlier this is not possible because it is as if you send message from me to me.... soon I will have to use the "Addreplayto", thank you very much for the help , the two

Show 10 more comments

1 answer

0


To use the smtp Gmail using Phpmailer the procedure occurs in two ways:

  • first: less secure (used on localhost during development or in domains without certificate): "Enable access to less secure apps" in your goolgle account you should go to the settings page => go to the security tab and upon arriving at Disable access to less secure apps enable access. The shortest path via browser would be (being logged in to your account) "https://www.google.com/settings/security/lesssecureapps" 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 pata TLS certificates if you do not use a certified connection you must use the aspmx.l.google.com on port 25 bad this restricts sending only to Gmail emails.

I use good for development on localhost Phpmailer works smoothly even with a self-signed certificate, as your case (it seems to me) already own a domain (?) because you want to send emails from the contact page, I recommend this link to take a look.

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

To do this you need to create an app to use authentication (XOAUTH2) and in your Phpmailer configuration add the authentication key.

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

https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2

And of course take a look at your Phpmailer examples folder of how to use google xoauth or:

https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail_xoauth.phps

If you have errors return the description.

  • Thanks for the reply. Either using ssl or tls always returns errors ( as you can see above in the post comments). I pass the email, either from outlook or gmail, and respective pass and always returns errors as you can see above.... I think it might be connected to permissions

  • Good your error reports that it was a password error... are you using smtp to receive to your Gmail account or relay to another account? If it is relay I advise you to look at the link I indicated to look. There speaks Coo use smtp with more technical details.

  • What I am doing or trying is the following: a person enters the website and has the contact form where hints his name email password of his email subject and message and this email will be sent to one that I created that received all.... What I created and gmail ie for example [email protected]

  • I’m sorry if I’m wrong, but you can’t use your contact page to access someone else’s account. Your php (in Phpmailer) should contain your account data, not who is contacting you. Suppose you just say, "Log in to the website and have the concto form where you hint your email name password of your email subject and message" if that’s really what you’re doing, you’ll make a mistake.The !?!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.