I have a system where when the user registers, system will send an email to the user with activation link. I am doing this process using SMTP connect(). But it asks for user's credentials ( with password) to whom I want to send the email, which makes no sense in the production level. How can I do this without knowing the user credentials?
Asked
Active
Viewed 282 times
0
-
1What other parameters are you setting? Are you setting the SMTP server correctly for each domain? – Zac Faragher May 06 '17 at 00:54
-
$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->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 I think they are correct – Proteeti Prova May 06 '17 at 01:06
-
1So are all the emails coming from Gmail accounts? The SMTP credentials that they enter will only be valid for a particular server, based on their email provider. – Zac Faragher May 06 '17 at 01:51
-
Possible duplicate of [send email using Gmail SMTP server through PHP Mailer](https://stackoverflow.com/questions/16048347/send-email-using-gmail-smtp-server-through-php-mailer) – Proteeti Prova Sep 03 '19 at 21:20
1 Answers
2
This has been covered many times on here - gmail doesn't allow you to send from arbitrary addresses, and asking for user's credentials to allow sending from their account is just bonkers; nobody should ever do that. Don't send from the user; send from your own address and use the submitter's address as a reply-to address. That way you only need your own credentials and will not be forging the from address.

Synchro
- 35,538
- 15
- 81
- 104