質問

I am trying to send a mail using Yii framework. Referred these tutorial.

Downloaded mail folder and named that folder 'mailer'.
And added that folder to extension folder in protected.

Now I got the error Fatal error: Call to undefined function IsSMTP() in C:\wamp\www\jobsite_orginal\protected\modules\jobseeker\controllers\SiteController.php on line 90.

Line 90 is IsSMTP();

Controller code

IsSMTP();
$mailer->IsHTML(true);
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = "ssl";
$mailer->Host = "smtp.gmail.com";
$mailer->Port = 465;
$mailer->Username = "test@aslingga.com";
$mailer->Password = "testpasswdxxx";
$mailer->From = "test@aslingga.com";
$mailer->FromName = "Test";
$mailer->AddAddress("user@example.com");
$mailer->Subject = "Someone sent you an email.";
$mailer->Body = "Hi, This is just a test email using PHP Mailer and Yii Framework.";
if (!$mailer->Send())
{
    echo "Message sent successfully!";
}
else 
{
    echo "Fail to send your message!";
}
役に立ちましたか?

解決

You first need to include the PHPMailerAutoload.php

I am assuming that you have saved this extension as protected/extensions/mailer/your_extension

Add the folllowing line at the top of your code

  include_once Yii::getPathOfAlias('application.extensions.mailer') . '/Emailer.php';

// and then rest of your code.

他のヒント

Try with a Google account, because you used STMP - Gmail

$mailer->Username = "something@gmail.com";
$mailer->Password = "your_gmail_password";

You are getting the Fatal error because you are using phpMailer's class methods without importing/including the phpMailer class.

Import the phpMailer class at beginning of your code.

      //As per current phpmailer exentions documentation this line will solve the problem.
      Yii::import('application.extensions.phpmailer.JPhpMailer');
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top