PHPmailer SMTP auth configuration

Drew picture Drew · Mar 31, 2015 · Viewed 13.5k times · Source

Something doesn't work with my phpmailer smtp. The php page should connect to an smtp authenticated server (with username and password), then authenticate to the specific mailbox I choose with username and password.

Basically I have a two-step authentication: one to the server, one to the mailbox.

  • What the username and password below refer to?
  • How could I login to the server (with user and password) and then to the mailbox (other user and other password)?

Thank you to who will be able to help me.

// SMTP auth
$mail->IsSMTP();
$mail->SMTPAuth     = ($smtp['auth'] ? true : false);
$mail->SMTPSecure   = ($smtp['secure'] ? $smtp['secure'] : false);
$mail->Host         = $smtp['host'];
$mail->Port         = $smtp['port'];
$mail->Username     = $smtp['username'];
$mail->Password     = $smtp['password'];

Answer

dartonw picture dartonw · Mar 31, 2015

To send email using SMTP authentication, you only need to log in once with a username and password permitted to relay through that server. When an SMTP server is also the Mail Exchanger (MX) for a domain, the username and password used for SMTP authentication are usually the same as those used to receive email using POP3/IMAP, where the mailbox exists on a Mail Delivery Agent (MDA) .

SMTP has no concept of mailboxes, it is only concerned with accepting messages from Mail User Agents (MUA), receiving messages from Message Transfer Agents (MTA) or submitting emails to a Mail Submission Agent (MSA), all of which communicate using the SMTP protocol.