Moshin
Moshin

Reputation: 191

Email System in PHP using PHPMailer

Hi i am currently implementing an email system for a customer in php. I'm having a bit of trouble in figuring out something. Here's a sample code:

   $mail = new PHPMailer();  // create a new object
   $mail->IsSMTP(); // enable SMTP
   $mail->SMTPDebug = 0;  // 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;
   $mail->Username = "***missing part***";
   $mail->Password = "***missing part***";
   $mail->SetFrom($from, $from_name);
   $mail->Subject = $subject;
   $mail->Body = $body;
   $mail->AddAddress($to);

My customer already created a business email account on gmail for this website. My question is should i put this business email and password in these missing parts? Anyone could help me please? Thanks.

Upvotes: 0

Views: 436

Answers (3)

Adam Purdie
Adam Purdie

Reputation: 502

Often web hosts don't use authentication for their web servers to send email using their smtp servers, i would suggest contacting the people who host the website and ask them about using their smtp servers.

Using gmail (if you can from a script) might end up with the rather annoying reply thing that you get from gmail where the reply address is a gmail account.

e.g. from [email protected] on behalf of [email protected] which doesn't look awesome :)

Upvotes: 0

Pekka
Pekka

Reputation: 449425

whose username and password should i put there?

If you want to use GMail, you need to put in the username and password that belong to the GMail account you want to send the message from.

.... which is why sending E-Mail through GMail is a bit of an imperfect solution IMO - you put your personal Google login data, with which you can access everything you do on Google, into a script on a server. It's not great practice security-wise.

It might be more feasible to create a SMTP account on the client's web site, and use that. That has the additional advantage that you can use a [email protected] sender address.

Upvotes: 1

Daniel
Daniel

Reputation: 1341

you must post the username and password so we can help you.. LOL, just kidding. You should put there the username and password of the account that would be sending the email. In this case, probably your webpage's gmail account.

Upvotes: 0

Related Questions