mantis smtp推送邮件失败解决
来源:互联网 发布:微博发淘宝优惠券 编辑:程序博客网 时间:2024/05/16 08:58
在实施mantis过程中,发现无论如何配置config_default_inc.php中关于smtp的选项,发送邮件都不能成功,无论是linux下,还是window下。但如果是自己写了一段phpmailer的测试代码,发现邮件发送正常,通过对比,发现修改mantis/core/email_api.php中的红色部分,就能成功。
function email_send( $p_email_data ) {
global $g_phpMailer;
$t_email_data = $p_email_data;
$t_recipient = trim( $t_email_data->email );
$t_subject = string_email( trim( $t_email_data->subject ) );
$t_message = string_email_links( trim( $t_email_data->body ) );
$t_debug_email = config_get( 'debug_email' );
$t_mailer_method = config_get( 'phpMailer_method' );
if( is_null( $g_phpMailer ) ) {
if ( $t_mailer_method == PHPMAILER_METHOD_SMTP )
register_shutdown_function( 'email_smtp_close' );
if( !class_exists( 'PHPMailer' ) ) {
require_once( BASE_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'phpmailer' . DIRECTORY_SEPARATOR . 'class.phpmailer.php' );
}
$mail = new PHPMailer(true);
} else {
$mail = $g_phpMailer;
}
if( isset( $t_email_data->metadata['hostname'] ) ) {
$mail->Hostname = $t_email_data->metadata['hostname'];
}
# @@@ should this be the current language (for the recipient) or the default one (for the user running the command) (thraxisp)
$t_lang = config_get( 'default_language' );
if( 'auto' == $t_lang ) {
$t_lang = config_get( 'fallback_language' );
}
$mail->SetLanguage( lang_get( 'phpmailer_language', $t_lang ) );
# Select the method to send mail
switch( config_get( 'phpMailer_method' ) ) {
case PHPMAILER_METHOD_MAIL:
$mail->IsMail();
break;
case PHPMAILER_METHOD_SENDMAIL:
$mail->IsSendmail();
break;
case PHPMAILER_METHOD_SMTP:
$mail->IsSMTP();
// SMTP collection is always kept alive
// $mail->SMTPKeepAlive = true;
if ( !is_blank( config_get( 'smtp_username' ) ) ) {
# Use SMTP Authentication
$mail->SMTPAuth = true;
$mail->Username = config_get( 'smtp_username' );
$mail->Password = config_get( 'smtp_password' );
}
if ( !is_blank( config_get( 'smtp_connection_mode' ) ) ) {
$mail->SMTPSecure = config_get( 'smtp_connection_mode' );
}
$mail->Port = config_get( 'smtp_port' );
break;
}
$mail->IsHTML( false ); # set email format to plain text
$mail->WordWrap = 80; # set word wrap to 50 characters
$mail->Priority = $t_email_data->metadata['priority']; # Urgent = 1, Not Urgent = 5, Disable = 0
$mail->CharSet = $t_email_data->metadata['charset'];
$mail->Host = config_get( 'smtp_host' );
$mail->From = config_get( 'from_email' );
$mail->Sender = config_get( 'return_path_email' );
$mail->FromName = config_get( 'from_name' );
if( OFF !== $t_debug_email ) {
$t_message = 'To: ' . $t_recipient . "\n\n" . $t_message;
try {
$mail->AddAddress( $t_debug_email, '' );
} catch ( phpmailerException $e ) {
$t_success = false;
$mail->ClearAllRecipients();
$mail->ClearAttachments();
$mail->ClearReplyTos();
$mail->ClearCustomHeaders();
return $t_success;
}
} else {
try {
$mail->AddAddress( $t_recipient, '' );
} catch ( phpmailerException $e ) {
$t_success = false;
$mail->ClearAllRecipients();
$mail->ClearAttachments();
$mail->ClearReplyTos();
$mail->ClearCustomHeaders();
return $t_success;
}
}
$mail->Subject = $t_subject;
$mail->Body = make_lf_crlf( "\n" . $t_message );
if( isset( $t_email_data->metadata['headers'] ) && is_array( $t_email_data->metadata['headers'] ) ) {
foreach( $t_email_data->metadata['headers'] as $t_key => $t_value ) {
switch( $t_key ) {
case 'Message-ID':
/* Note: hostname can never be blank here as we set metadata['hostname']
in email_store() where mail gets queued. */
if ( !strchr( $t_value, '@' ) && !is_blank( $mail->Hostname ) ) {
$t_value = $t_value . '@' . $mail->Hostname;
}
$mail->set( 'MessageID', "<$t_value>" );
break;
case 'In-Reply-To':
$mail->AddCustomHeader( "$t_key: <{$t_value}@{$mail->Hostname}>" );
break;
default:
$mail->AddCustomHeader( "$t_key: $t_value" );
break;
}
}
}
try
{
if ( !$mail->Send() ) {
$t_success = false;
} else {
$t_success = true;
if ( $t_email_data->email_id > 0 ) {
email_queue_delete( $t_email_data->email_id );
}
}
}
catch ( phpmailerException $e )
{
$t_success = false;
}
$mail->ClearAllRecipients();
$mail->ClearAttachments();
$mail->ClearReplyTos();
$mail->ClearCustomHeaders();
return $t_success;
}
- mantis smtp推送邮件失败解决
- 向smtp发送邮件失败
- smtp 发送邮件 乱码解决
- PHPMailer发送邮件失败:SMTP connect failed
- PHPMailer发送邮件失败:SMTP connect failed
- 阿里云发送SMTP邮件失败
- smtp发送邮件失败-邮件标头找到无效字符
- 邮件:事务失败。 服务器响应为:DT:SPM 163 smtp
- mantis邮件乱码解决方法
- mantis不能发送邮件
- mantis邮件服务配置
- Mantis邮件服务器配置
- mantis邮件配置
- Mantis邮件设置
- mantis邮件配置
- 解决Jpush大批量循环推送失败
- 友盟推送deviceToken获取失败解决
- Configure SMTP插件解决WordPress邮件发送问题
- 你有没有变成自己想要的那个你?
- const指针
- 同样的内核配置,不同的编译器结果不同
- #ifdef /#if
- 四则运算(表达式求值)
- mantis smtp推送邮件失败解决
- ASP.NET web.config的session配置详解
- 提高PHP的运行效率的方法
- annotation配置action
- Devpress之ASPxGridLookup(二)
- 山东联通计费系统容灾及查询平台应用--案例
- 百度推广,医院网络营销的毒品?
- 两表并列
- oracle左右连接的另外表示方法-括号加号