2

I wanna subscribe my website newsletter members to my Google Group automatically.

I try send email to mygroupname+subscribe@googlegroups.com with subject & body "subscribe" by PHP Mail function from user email. but not any result and subscription resquest in my group.

  $phpMailSender = new PHPMailer();
  $phpMailSender->CharSet = "UTF-8";

  foreach($users as $user) {
        $phpMailSender->ClearAddresses();

        $phpMailSender->From = $user['email'];
        $phpMailSender->FromName = $user['email'];
        $phpMailSender->AddReplyTo($user['email']);

        $phpMailSender->addAddress('mygroupname+subscribe@googlegroups.com');

        $phpMailSender->Subject = 'subscribe';
        $phpMailSender->Body = 'subscribe';
        $result = $phpMailSender->send();

        if($result)
                echo "Subscription email Sent for user# " . $user['email'] . "\n";
        else
                echo "Subscription email failed for user# " . $user['email'] . "\n";

        ob_flush();
        flush();
  }

Can any one help me!

Dzoki
  • 739
  • 4
  • 14
Akbar
  • 61
  • 5

1 Answers1

0

Whilst looking at a question in the hMailServer forum.

The fellow there gives some ideas on how to do this (albeit, no code), but there are good considerations.

But there is a bit more involved than just subscribing the user to the list. You also need to validate the email address the user provides so that people don't enter other people's email addresses. This would be done by sending an email to the user and asking him to confirm his subscription. When he clicks the link to confirm, he goes to your webpage that is keyed to a database entry somewhere, and then the email gets added to the list in a manner that you are attempting.

But check out the link I provide above for a few more considerations.

Here is another similar thread.

As for code, there is a snippet here.

This thread also has some php code, similar to yours - you should look at this.

Community
  • 1
  • 1
bgmCoder
  • 6,205
  • 8
  • 58
  • 105