Problem with sending outside domain
Posted: Thu Oct 23, 2008 6:31 am
Hi,
I've got problem with sending e-mail outside domain. I've created code:
Function is running under Symfony framework.
My domain is (for example) domain.com and when I send newsletter to account in this domain (for example user@domain.com) the e-mail arrives but when I send newsletter to other domain (user@blablabla.com) it doesn't.
I tried using mail() function in other script (with mail() function only) and everything was fine.
Could You help me and give me some suggestions?
pion
I've got problem with sending e-mail outside domain. I've created code:
Code: Select all
public function executeSendDo() {
if ($this->getRequest()->isXmlHttpRequest()) {
$mailId = (int)$this->getRequest()->getParameter('mailId', 0);
$mail = NewsletterMailPeer::getJoinTemplate($mailId);
if ($mail !== false) {
$mails = NewsletterMailPeer::getCurrentRecipients($mail->getId());
// users for newsletter were found
if (isset($mails[0])) {
$areForText = false;
$areForHtml = false;
$textRecipients = new Swift_RecipientList();
$htmlRecipients = new Swift_RecipientList();
foreach ($mails as $m) {
// user preferes mail as plain text
if ($m['newsletter_type'] == '1') {
$textRecipients->addTo($m['email'], $m['nickname']);
$areForText = true;
}
// ...or as HTML.
elseif ($m['newsletter_type'] == '2') {
$htmlRecipients->addTo($m['email'], $m['nickname']);
$areForHtml = true;
}
}
$swift = new Swift(new Swift_Connection_NativeMail());
$batch = new Swift_BatchMailer($swift);
if ($areForText === true) {
$textMessage = new Swift_Message($mail->getTitle(), $mail->getTextBody());
$batch->send($textMessage, $textRecipients, 'newsletter@domain.com');
}
if ($areForHtml === true) {
$htmlMessage = new Swift_Message($mail->getTitle(), $mail->getHtmlBody(), 'text/html');
$batch->send($htmlMessage, $htmlRecipients, 'newsletter@domain.com');
}
NewsletterSentPeer::insertRecipients($mails, $mailId);
echo '1';
}
// sending is finished
else {
$mail->setIsFinished(true);
$mail->setFinishedAt(time());
$mail->save();
echo '0';
}
}
else {
echo '1';
}
}
return sfView::NONE;
}My domain is (for example) domain.com and when I send newsletter to account in this domain (for example user@domain.com) the e-mail arrives but when I send newsletter to other domain (user@blablabla.com) it doesn't.
I tried using mail() function in other script (with mail() function only) and everything was fine.
Could You help me and give me some suggestions?
pion