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";
}
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.
– Daniel Omine
If using gmail smtp is not necessary but if using the postmarkapp is necessary
– Adriano Maia
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?
– Daniel Omine
I when I get home put the errors that appear to me using gmail smtp
– Adriano Maia
@Danielomine this here the mistakes that appear to me when for example I want the "From" to be from a Hotmail for example :
– Adriano Maia
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.
– Adriano Maia
It is not allowed to set a
From
different from the email used in authentication. Currently virtually all email services block. In the directiveFrom
, put the same email you’re using for authentication and then you’ll see that it works.– Daniel Omine
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
– Adriano Maia
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.
– Daniel Omine
Is there any way to overcome this problem? And I need it to work for all emails....
– Adriano Maia
Simply set up a gmail account for authentication, as I have repeatedly commented in the comments above. http://answall.com/search?q=gmail+phpmailer
– Daniel Omine
Okay thanks I’ll try later say something thanks for the help
– Adriano Maia
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 !!!
– Lauro Moraes
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?
– Adriano Maia
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
– Adriano Maia