0

phpMailer と GMail SMTP を使用してメールを送信しようとしています。他の Gmail アカウントにメールを送信することは問題なく機能しますが、Yahoo に送信するとメールが届きません。IP アドレスなどを使用したデバッグについて読みましたが、その分野のスキルがありませんか?

コードは次のとおりです。

  $mail->Mailer='smtp';

   try {
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 587;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "__email__";  // GMAIL username
    $mail->Password   = "__pass__";            // GMAIL password
    $mail->SMTPDebug  = 2;

    $a = md5(uniqid(rand(), true)); //create a unique validation code

    //These are the variables for the email

    $mail->AddAddress (trim($_POST['email']),trim($_POST['username'])); // this is the email address collected form the form
    $mail->Subject = "Registration"; // Subject
    $mail->Body = "Thank you for registering\n your security code is ".$a;
    $mail->Send();


    echo "check your email to complete registration"; 
   } catch (phpmailerException $e) {
     echo $e->errorMessage(); //Pretty error messages from PHPMailer
   } catch (Exception $e) {
     echo $e->getMessage(); //Boring error messages from anything else!
   }

   $mail->ClearAddresses();

更新: 問題が見つかりました: 私たちのサーバーは Yahoo によってブラックリストに登録されていたので (私のせいではありません)、1 日半が無駄になりました。

4

2 に答える 2

0

Gmailユーザーと連携しているので、私のゲストは、一部のphpMailerがユーザー名とパスワードを正しく送信していないということです。認証されていない場合、Gmailサーバーはメールの中継を受け入れません。

1つの質問ですが、独自の電子メールサーバーを使用しないのはなぜですか。デバッグして、電子メールが送信されない理由を知るのに役立ちます。

于 2010-12-15T02:37:17.627 に答える
0

gmail の代わりに、Google App Engine のメール サービスを使用することをお勧めします。それはあなたのためにすべての面倒な作業を行います。また、アプリエンジンの送信制限ははるかに高いのに対し、gmail には送信制限があるためです。また、寛大な無料割り当て (1000 受信者/日.

現在サインインしているユーザーからメッセージを送信する例を次に示します。login_required アノテーションを使用して、サインインしていないユーザーをサインイン ページにリダイレクトします。

from google.appengine.api import mail
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import login_required

class InviteFriendHandler(webapp.RequestHandler):
    @login_required
    def post(self):
        to_addr = self.request.get("friend_email")
        if not mail.is_email_valid(to_addr):
            # Return an error message...
            pass

        message = mail.EmailMessage()
        message.sender = users.get_current_user().email()
        message.to = to_addr
        message.body = """
I've invited you to Example.com!

To accept this invitation, click the following link,
or copy and paste the URL into your browser's address
bar:

%s
        """ % generate_invite_link(to_addr)

        message.send()
于 2010-12-15T04:59:14.740 に答える