[EXTENSION] Mailer using PHPMailer
#21
Posted 09 June 2009 - 06:51 PM
this is certainly a silly question:
I want to use a helper function or class to send an Email with Emailer extension, because I dont want to configure the mailer within the controller every time.
Where is the best place for it? How to extend the component extension correctly?
the function is something like this: function sendMail($to, $subject, $body){}
#22
Posted 09 June 2009 - 08:13 PM
Quote
this is certainly a silly question:
I want to use a helper function or class to send an Email with Emailer extension, because I dont want to configure the mailer within the controller every time.
Where is the best place for it? How to extend the component extension correctly?
the function is something like this: function sendMail($to, $subject, $body){}
You can find and example in the documentation tab of the extension.
#23
Posted 10 June 2009 - 05:11 AM
- create a class MyApp in protected/helpers folder
- create a function MyApp::sendMail($to, $subject, $body)
- import application/helpers.*
- added the Emailer to application components
#24
Posted 05 March 2010 - 03:17 AM
Currently I have to copy the views to the views folder in the protected directory.
Cheers,
Sn0rcha
#25
Posted 11 June 2010 - 12:06 PM
But How can I do to send a e-mail with images ?? I mean that the content of the e-mail contains images. (Not attachments).
I research and I need to specify some headers.. but using this extension how can I do that?
#26
Posted 11 November 2010 - 01:34 AM
'components'=>array(
'mailer' => array(
'class' => 'application.extensions.mailer.EMailer',
'pathViews' => 'application.views.email',
'pathLayouts' => 'application.views.layouts'
),
this wont change the
protected $pathLayouts = 'application.views.email.layouts';
i ve to change it manualy on the emailer.php
is there any mistake?
Tidak ada coding yang salah
Yang ada hanyalah Coding yang lebih baik
#27
Posted 15 June 2012 - 06:14 PM
Yii::app()->mailer->Host = 'smtpout.secureserver.net'; Yii::app()->mailer->IsSMTP(true); Yii::app()->mailer->Username = "info@****.com"; Yii::app()->mailer->Password = "****"; Yii::app()->mailer->From = 'info@****.com'; Yii::app()->mailer->FromName = '****'; Yii::app()->mailer->IsHTML(true); Yii::app()->mailer->CharSet = 'UTF-8'; Yii::app()->mailer->AddReplyTo('info@****.com'); Yii::app()->mailer->AddAddress($********->email); Yii::app()->mailer->Subject = '****'; Yii::app()->mailer->Body = $message; if(!$mailer->Send()) { $this->actionBad(); throw new CHttpException(500, 'Something went horribly wrong'); } else { $this->actionOk(); }
I get: "SMTP Error: Could not connect to SMTP host. Transaction Failed!"
I have enabled SMTP relay on the account and I still get this problem.
PS: one more question, is there a way of connecting with SSL using this extension?
EDIT:
Made it work - just had to put "relay-hosting.secureserver.net" into host part of the setup.
Continuing to work on SSL setup.
EDIT:
getting connection refused. I'm using 465 port, SMTPSecure = 'ssl' SMTPAuth = True.
This post has been edited by psolovyov: 15 June 2012 - 07:03 PM
#28
Posted 15 June 2012 - 09:20 PM
psolovyov, on 15 June 2012 - 06:14 PM, said:
I used this extension on one of my previous projects, and ssl connection works fine so far with these configs:
$this->SMTPDebug = false;
$this->Mailer='smtp';
$this->SMTPAuth=true;
$this->SMTPSecure='ssl';
$this->Host="smtp.gmail.com";
$this->Port=465;
$this->CharSet = 'utf-8';
$this->ContentType = 'text/html';
$this->WordWrap = 70;
$this->FromName=Yii::app()->name;
$this->setFrom=Yii::app()->params->siteEmail;
$this->Username = // SMTP username
$this->Password = // SMTP password
#29
Posted 15 June 2012 - 09:22 PM
psolovyov, on 15 June 2012 - 06:14 PM, said:
I used this extension on one of my previous projects, and ssl connection works fine so far with these configs:
$this->SMTPDebug = false;
$this->Mailer='smtp';
$this->SMTPAuth=true;
$this->SMTPSecure='ssl';
$this->Host="smtp.gmail.com";
$this->Port=465;
$this->CharSet = 'utf-8';
$this->ContentType = 'text/html';
$this->WordWrap = 70;
$this->FromName=Yii::app()->name;
$this->setFrom=Yii::app()->params->siteEmail;
$this->Username = // SMTP username
$this->Password = // SMTP password
#30
Posted 21 June 2012 - 01:45 PM
yugene, on 15 June 2012 - 09:22 PM, said:
$this->SMTPDebug = false;
$this->Mailer='smtp';
$this->SMTPAuth=true;
$this->SMTPSecure='ssl';
$this->Host="smtp.gmail.com";
$this->Port=465;
$this->CharSet = 'utf-8';
$this->ContentType = 'text/html';
$this->WordWrap = 70;
$this->FromName=Yii::app()->name;
$this->setFrom=Yii::app()->params->siteEmail;
$this->Username = // SMTP username
$this->Password = // SMTP password
i tried this but I get
SMTP -> ERROR: Failed to connect to server: Connection refused (111) SMTP Error: Could not connect to SMTP host. Transaction Failed!
My settings:
Yii::app()->mailer->SMTPDebug = true; Yii::app()->mailer->Mailer='smtp'; Yii::app()->mailer->SMTPAuth=true; Yii::app()->mailer->SMTPSecure='ssl'; Yii::app()->mailer->Host="smtp.gmail.com"; Yii::app()->mailer->Port=465; Yii::app()->mailer->From = 'info@*******.com'; Yii::app()->mailer->FromName = '****'; Yii::app()->mailer->setFrom('info@****.com'); Yii::app()->mailer->AddReplyTo('info@****.com');*/ Yii::app()->mailer->AddAddress($client_email->email); Yii::app()->mailer->ContentType = "text/html"; Yii::app()->mailer->CharSet = 'UTF-8'; Yii::app()->mailer->Subject = '****'; Yii::app()->mailer->Body = $message; Yii::app()->mailer->Username = "****@gmail.com"; Yii::app()->mailer->Password = "****"; if(!Yii::app()->mailer->Send()) { $this->actionBad(); throw new CHttpException(500, 'Something went horribly wrong'); } else { $this->actionOk(); }
EDIT: DUH!!! Talked to guys in chat and figured out that I need to use SMTPS instead of SMTP. WOrks perfectly now.
Thanks!!!
#31
Posted 08 November 2012 - 03:06 AM
Apologies in advance if someone has already raised this, but there is a small logic error in the phpmailer class on line 1236 in the addAttachments function.
The last element of the array is set to 0, this is the unique id for the attachment, therefore it will stop any subsequent attachments from being added by the AttachAll function.
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'attachment',
7 => 0, // <= THIS LINE HERE
);
If you change it to increment you can send more than 1 attachment per email.
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'attachment',
7 => count($this->attachment),
);
The error is present in the current version of the mailer extension.
Cheers
Ben
#32
Posted Today, 09:48 AM
this is my code...
in config main file
'mailer' => array( 'class' => 'application.extensions.mailer.EMailer', 'pathViews' => 'application.views.email', 'pathLayouts' => 'application.views.email.layouts' ),
in my controller i using this code for sending the mail..
// Reading the content of mail from view..
$html = $this->renderPartial('//email/email',array(),true);
Yii::app()->mailer->Body = $html;
Yii::app()->mailer->Send();

Help
















