Just to make sure I am assuming that Swift_Connection_NativeMail uses the standard PHP mail() correct?
If that is true I have 1 customer where using Swift_Connection_NativeMail the email doesn't go out. If I comment it out and use mail() instead it works fine.
Any suggestions?
NativeMail not working where as PHPMail is
Moderators: Chris Corbyn, General Moderators
- Technocrat
- Forum Contributor
- Posts: 127
- Joined: Thu Oct 20, 2005 7:01 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Technocrat
- Forum Contributor
- Posts: 127
- Joined: Thu Oct 20, 2005 7:01 pm
When I say 1 customer that means somewhere in the neighborhood of 5K other people are using it just fine. Which is why I think its a problem on their server end. Just like the last problem I posted here.
So if I take out $sent = $swift->send($message, $to, $from); and use mail() instead it goes out just fine.
Code: Select all
function evo_mail($to, $subject, $content, $header='', $params='', $batch=false, $from='', $replyto='') {
global $board_config, $nukeconfig, $cache;
if (empty($to)) return false;
require_once (NUKE_INCLUDE_DIR.'mail/Swift.php');
require_once (NUKE_INCLUDE_DIR.'mail/Swift/Connection/Multi.php');
require_once (NUKE_INCLUDE_DIR.'mail/Swift/Connection/Sendmail.php');
require_once (NUKE_INCLUDE_DIR.'mail/Swift/Connection/SMTP.php');
require_once (NUKE_INCLUDE_DIR.'mail/Swift/Connection/NativeMail.php');
//If for some reason there is a , in the $to and its not a swift recipient list
if (!is_object($to) && strchr($to, ',')) {
//Break it up
$tos = explode(',', $to);
//Mak it a swift recipient list
$to =& new Swift_RecipientList();
foreach ($tos as $address) {
$to->addTo($address, $address);
}
}
//If there is no from
if (empty($from)) {
//If the nuke config is empty or is set to default
if (!isset($nukeconfig['adminmail']) || empty($nukeconfig['adminmail']) || $nukeconfig['adminmail'] == 'webmaster@------.---') {
//If the board email is empty or set to default
if (!isset($board_config['board_email']) || empty($board_config['board_email']) || $board_config['board_email'] == 'Webmaster@MySite.com') {
//Give an error
die(_ERROR_EMAIL);
} else {
$from = $board_config['board_email'];
}
} else {
$from = $nukeconfig['adminmail'];
}
}
//If for some reason there is a , in the from
if (strchr($from, ',')) {
//Get rid of it
$from = substr($from, 0, strpos($from, ','));
}
//If the forums are set to SMTP
if (isset($board_config['smtp_delivery']) && $board_config['smtp_delivery'] == '1') {
//If the board is set to use SMTP but there is no username for it
if (empty($board_config['smtp_username']) || empty($board_config['smtp_username'])) {
$swift =& new Swift(new Swift_Connection_SMTP($board_config['smtp_password']));
} else {
$smtp =& new Swift_Connection_SMTP($board_config['smtp_host'], 25);
$smtp->setUsername($board_config['smtp_username']);
$smtp->setpassword($board_config['smtp_password']);
$swift =& new Swift($smtp);
}
//If not using SMTP
} else {
//Uncomment define at the top to use sendmail
if (defined('SENDMAIL')) {
$sendmail_path = @ini_get('sendmail_path');
$sendmail_path = str_replace(' -i', '', $sendmail_path);
if (function_exists('proc_open') && !empty($sendmail_path)) {
$swift =& new Swift(new Swift_Connection_Sendmail($sendmail_path));
} else {
$swift =& new Swift(new Swift_Connection_NativeMail());
}
} else {
$swift =& new Swift(new Swift_Connection_NativeMail());
}
}
//Change new lines to HTML new lines
$content = str_replace("\r\n", "<br />", $content);
$content = str_replace("\n", "<br />", $content);
//If cache is valid and using file cache
if ($cache->valid && $cache->type == 1) {
//Use it with swift cache
Swift_CacheFactory::setClassName("Swift_Cache_Disk");
Swift_Cache_Disk::setSavePath(NUKE_CACHE_DIR);
}
//Start a new message
$message =& new Swift_Message($subject, $content, "text/html");
//If there was a reply to
if (!empty($replyto)) {
$message->setReplyTo($replyto);
}
//If its a batch job
if ($batch && is_object($to)) {
$sent = $swift->batchSend($message, $to, $from);
} else {
$sent = $swift->send($message, $to, $from);
}
//Disconnect from the mail server
$swift->disconnect();
return $sent;
}- Technocrat
- Forum Contributor
- Posts: 127
- Joined: Thu Oct 20, 2005 7:01 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Technocrat
- Forum Contributor
- Posts: 127
- Joined: Thu Oct 20, 2005 7:01 pm