coder123
(Aniltc)
February 16, 2017, 9:41am
1
Hi all
I use swiftmailer for sending mail and my code is
$mailSubject = "Membership Form Verification - Approved";
$mailBody = $this->renderPartial('//mails/approvetemplate', ['compname'=>$compname, 'status'=>'Approved']);
Yii::$app->mail->compose()
->setTo($toEmail)
->setBcc($fromEmail)
->setFrom([$fromEmail => $fromName])
->setSubject($mailSubject)
->setHtmlBody($mailBody)
->send();
But my users are compaining that the mail doesn’t come to inbox what should I do ?
Hi Anilcoder,
That is not enough information to help.
It could have a ton of reasons when your emails are detected as spam.
Also there are a lot of resources on the web to figure out why your emails are detected as spam.
For example:
(… Ignore the self-advertisement of sendgrid, just read the blog post. )
Just google for: "yii2 why are my emails spam"
You find or example:
http://www.yiiframework.com/forum/index.php/topic/59473-email-message-in-spam/
Also we would need more details about your email configuration.
Are you using own hosted/rent Mailserver?
Or are you using - for example - Gmail-Servers to relay/forward your emails to the users? From my experience a common mistake is using for example google mailservers and faking the "from" address…
Regards
coder123
(Aniltc)
February 16, 2017, 10:10am
3
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
//'useFileTransport' => true, //for the testing purpose, you need to enable this
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.office123.com',
'username' => 'info@mydomain.com',
'password' => 'fghgfh',
'port' => '587',
'encryption' => 'tls',
],
],
Here is my swiftmailer config
tamalkundu
(Idio Tamal17)
February 17, 2017, 7:48am
4
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
//'useFileTransport' => true, //for the testing purpose, you need to enable this
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.office123.com',
'username' => 'info@mydomain.com',
'password' => 'fghgfh',
'port' => '587',
'encryption' => 'tls',
],
],
Here is my swiftmailer config
Hello buddy You can simply use the php mail function…It will work absolutely perfect…
phtamas
(Phtamas)
February 17, 2017, 4:12pm
5
Building multipart messages with attachments, etc., safely escaping all user inputs and creating proper headers manually isn’t too much fun, requires quite a bit of knowledge about standards and extremely error-prone.
Also, depending on your OS and PHP configuration, mail() might happily return TRUE- even if your SMTP server is down (or simply not yet installed). And when it returns FALSE - good luck with debugging it. I prefer to have a bit more detailed and more reliable feedback about my emails.
tamalkundu
(Idio Tamal17)
February 20, 2017, 9:06am
6
phtamas:
Building multipart messages with attachments, etc., safely escaping all user inputs and creating proper headers manually isn’t too much fun, requires quite a bit of knowledge about standards and extremely error-prone.
Also, depending on your OS and PHP configuration, mail() might happily return TRUE- even if your SMTP server is down (or simply not yet installed). And when it returns FALSE - good luck with debugging it. I prefer to have a bit more detailed and more reliable feedback about my emails.
Well then, please suggest us any standard solution…cause I am in Yii2, having not too much knowledge about it…
Thank You