Diasline
Diasline

Reputation: 635

Amazon Simple Email Service SMTP using PHP Mailer

I finally find the solution of my problem, i post new codes that work properly. I have a new issue now, let say that my email has more than one destination, when i try to put many email adresses in $to variable. For exemple $to="[email protected],[email protected]"; it's not working but with only one it's worked. How can i do it with more than one address ?

$account="username";
 $password="password";
  $to="[email protected]";
 $from="[email protected]";
 $from_name="name";
 $msg="<strong>test smtp with amazon.</strong>"; // HTML message
 $subject="HTML message";
 require 'class.phpmailer.php';

  $mail = new PHPMailer();
 $mail->IsSMTP();
 $mail->CharSet = 'UTF-8';
 $mail->Host = "email-smtp.us-east-1.amazonaws.com";
 $mail->SMTPAuth= true;
 $mail->Port = 465; 
 $mail->Username= $account;
$mail->Password= $password;
 $mail->SMTPSecure = 'ssl';
 $mail->From = $from;
 $mail->FromName= $from_name;
 $mail->isHTML(true);
 $mail->Subject = $subject;
  $mail->Body = $msg;
  $mail->addAddress($to);

  if(!$mail->send()){
 echo "Mailer Error: " . $mail->ErrorInfo;
  }else{
  echo "E-Mail has been sent";
   }

Upvotes: 2

Views: 340

Answers (3)

S M Monjurul Islam
S M Monjurul Islam

Reputation: 56

For adding more than one email you can do it in the following way:

$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");
$mail->AddAddress("[email protected]");

Upvotes: 0

S M Monjurul Islam
S M Monjurul Islam

Reputation: 56

As u are using gmail u should less secure your app using this link after login to gmail. link: https://www.google.com/settings/security/lesssecureapps

host should be $mail->Host = "smtp.gmail.com"; for gmail.

Upvotes: 1

Stan Dudikoff
Stan Dudikoff

Reputation: 94

Do you completed validate e-mail [email protected] ? First you must go to

> https://console.aws.amazon.com/ses/

Then in Email Addresses checked there is your [email protected] address. If no click on Verify a New Email Address and add one. You'll get test message. After that in Verified Sender: Email row you will see next to your e-mail the green world "verified".

Upvotes: 0

Related Questions