Bosun fails to send alert - bosun

Bosun fails to send alert notification to mail configured with the below log.
error: notify.go:111: failed to send alert high.cpu{host=} to [*#gmail.com] EOF
This is my bosun.conf
tsdbHost = localhost:4242
stateFile = /data/bosun.state
ledisBindAddr = 0.0.0.0:9565
smtpHost = smtp.gmail.com:465
emailFrom = bosun-alert#noreply.com
notification email {
email = ***#gmail.com
next = email
timeout = 5s
print = true
}
template test {
subject = {{.Last.Status}}: {{.Alert.Name}} on {{.Group.host}}
body = `<p>Alert: {{.Alert.Name}} triggered on {{.Group.host}}
<hr>
<p><strong>Computation</strong>
<table>
{{range .Computations}}
<tr><td>{{.Text}}</td><td>{{.Value}}</td></tr>
{{end}}
</table>
<hr>
{{ .Graph .Alert.Vars.metric }}
<hr>
<p><strong>Relevant Tags</strong>
<table>
{{range $k, $v := .Group}}
<tr><td>{{$k}}</td><td>{{$v}}</td></tr>
{{end}}
</table>`
}
alert high.cpu {
template = test
$metric = q("sum:rate{counter,,1}:os.cpu{host=*}", "1h", "")
$avgcpu = avg($metric)
crit = $avgcpu > 3
warn = $avgcpu > 2
critNotification = email
warnNotification = email
}
Please help me figure what I am doing wrong.

Do you also have smtpUsername and smtpPassword in your bosun config? Without those you probably can't use Bosun email notifications. The email may also be rejected unless it matches your gmail address or has been validated in your gmail account. and I believe we use port 587 for smtp.gmail.com instead of 465.
Example:
smtpHost = smtp.gmail.com:587
emailFrom = youraccount#gmail.com
smtpUsername= youraccount#gmail.com
smtpPassword= yourpassword

Related

Contact form 7 email using SMTP

I created a web site using WordPress.
I added Contact Form 7 in my side bar.
After I filled the fields in the contact form, and click the Send button, I got an error message in a red box:
There was an error trying to send your message. Please try again
later.
I did not install phpmailer. I wrote a test php (testemail.php showed below). When I visit http://www.MyDomainName.com.au/testemail.php in the browser, it shows whole codes of the testemail.php!
Do I have to install a phpmailer plugin, for example, Easy WP SMTP?
What is the problem in testemail?
Finally how to make my contact form working?
The testemail.php code:
function sendMail($request) {
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 4;
$mail->isSMTP();
$mail->Host = mail#MyDomainName.com.au;
$mail->SMTPAuth = true;
$mail->Username = 'mail#MyDomainName.com.au';
$mail->Password = 'myPassword';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('mail#MyDomainName.com.au', 'Title');
$mail->addAddress(xxx#hotmail.com);
$mail->addReplyTo('mail#MyDomainName.com.au');
$mail->isHTML(true);
$mail->Subject = '$Something';
$mail->Body = 'The body of the email';
$mail->AltBody = 'Alternative'; // this is mostly sent to your own mail
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}

PHPMailer & WordPress "Post by Email" - not creating post

I'm creating a script for a client using their PHP 5.4.16 (updating is not in the scope of this project), and therefore PHPMailer 5.2.25. My script (below) works if I change the SetAddress to my personal Gmail account (I get the email with subject, body, and attachment (the latter being the reason for using PHPMailer)), but if I change the SetAddress to my WordPress "Post by Email" address, nothing seems to be delivered.
Questions:
Is there anything wrong with my script? Missing headers? Badly formatted email?
If my script is apparently OK, what other avenues of investigation might there be?
Thanks
<?php
echo "<p>" . date("h:i:sa");
?>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/../www/phpmailer/class.phpmailer.php'); ?>
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/../www/phpmailer/class.smtp.php'); ?>
<?php
$mail = new PHPMailer();
$mail->IsSMTP(); // enable SMTP
//$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 587; // or 587
$mail->IsHTML(true);
$mail->Username = "my#gmail.com";
$mail->Password = "mypassword";
$mail->From = "my#gmail.com";
$mail->FromName = "Me";
//$mail->AddAddress("caju317davu#post.wordpress.com");
$mail->AddAddress("my#gmail.com");
$mail->AddReplyTo("my#gmail.com","developer");
$mail->AddAttachment($_SERVER['DOCUMENT_ROOT'] . '/../www/_assets/articles/223/610/7f10120230e612e03eea9aa54a48a68f.jpg', 'attachment.jpg');
$mail->Subject = "My test email";
$mail->Body = "Hi! This is my first successful post created through email.";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
Now I am not sure if this will help at all but below is the code that I have for a working version of PHPMailer v5.2.9 that is running on a site using PHP version 5.4.16 so may help. The obvious differences I can see is the recipient's section don't have "set" or "Add" and also I can't seem to find the initiator ($mail->send();). Let me know if this helps and for any areas needing extra clarification.
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.host.co.uk'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mail#example.co.uk'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('email#example.co.uk', 'Company Name');
$mail->addAddress($email); //Gets the email the enquiry form field contains
$mail->addReplyTo('email#example.co.uk', 'Company Name');
$body='<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica,
sans-serif; font-size:12px; margin:0; padding:0;">
<p>Thank you for your enquiry, a member of the team will be in touch shortly to discuss your requirements. In the mean time, please double check the below details entered on our website. If any of these are incorrect or you wish to add to it, please contact us via email or over the phone.</p></div>';
//Content
$mail->isHTML(true);
$mail->Subject = $subject ;
$mail->Body = $body;
$mail->AltBody = strip_tags($body);
$mail->send();
echo $thankyou_text;
} catch (Exception $e) {
echo $failed_text;
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
From a 'Happiness Engineer' at WordPress:
Hi there!
At WordPress.com we don't allow posts to be sent automatically from
scripts such as PHPMailer.
I guess that answers that! Now to forget PHPMailer, and try and get back to default PHP mail() :(
Sorry to have bothered you all

Not getting alerts but acknowledgement of the alerts on dashboard work

I have been trying to get Bosun to work with little success. Here are my problems:
1) I am able to see alerts appearing in my dashboard, but the alerts never come thru to the notification mode of my choice, be it e-mail, slack or json.
2) When I acknowledge the alerts on the dashboard, only one notification from the notification chain (first one) will be received. I.e. If I set up {email -> slack -> json}, only e-mail notification will be received, no slack and json.
Any help will be appreciated. Below is my dev.config
-------------- dev.conf ---------------
tsdbHost = qa1-sjc005-031:4242
emailFrom = bosun-alert#noreply.com
smtpHost = stmp.somedomain.com:25
checkFrequency = 1m
httpListen = :8070
# Post to an endpoint
notification json {
post = http://somedomain.com/HealthCheck/bosunAlert
body = {"text": {{.|json}}}
contentType = application/json
print = true
next = json
timeout = 5m
}
# Post to a Slack channel via Incoming Webhooks integration
notification slack {
post = https://hooks.slack.com/services/T03DNM0UU/B04QH37J6/ypn0
Uy2JwLa676soomXwItjq
body = payload={"channel": "#testing", "username": "webhookbot"
, "text" : "This is a test!"}
print = true
next = json
timeout = 5m
}
# Send out e-mail notification
notification email {
email = username#somedomain.com
print = true
next = slack
timeout = 5m
}
template test {
subject = {{.Last.Status}}: {{.Alert.Name}} on {{.Group.measurem
ent}} for {{.Group.pod}}
body = `<p>Name: {{.Alert.Name}}
<p>Tags:
<table>
{{range $k, $v := .Group}}
<tr><td>{{$k}}</td><td>{{$v}}</td></tr>
{{end}}
</table>`
}
alert test {
template = test
crit = avg(q("avg:mq1{measurement=*,pod=pod3}", "1h", ""))
warn = avg(q("avg:mq1{measurement=*,pod=pod3}", "30m", ""))
critNotification = email
warnNotification = email
}
Acknowledgements stop notification chains. So the purpose of them is really for the escalation of incidents; escalation stops when an incident has been acknowledged. As per the documentation on notifications:
notification
A notification is a chained action to perform. The chaining continues until the chain ends or the alert is acknowledged.
It seems like you might want to send to multiple notifications at the same time. To do this list them out in warnNotification and/or critNotification as appropriate:
critNotification: comma-separated list of notifications to trigger on critical.
Both the quotes are from the configuration documentation (documentation isn't that well organized currently, so I don't blame you for missing either of these)

Webmail method email sender Name should be displayed

WebMail.Send(to: "someone#somewhere.com", subject: "email subject", body: "message body, isBodyHtml: false );
WebMail.SmtpServer = "smtp.gmail.com";
WebMail.SmtpPort = 587;
WebMail.EnableSsl = true;
WebMail.UserName = "me#mydomain.com";
WebMail.Password = "the password";
WebMail.From = "me#mydomain.com";
By using the above method, I am receiving email from sender name as "me#mydomain.com".. I tried changing the parameters "userName" and "From", but the gmail server rejects the message.
What parameter to add to receive email from a sender name instead of email id..
try this:
System.Web.Mail is not a full .NET native implementation of the SMTP
protocol. Instead, it uses the pre-existing COM functionality in
CDONTS. System.Net.Mail, in contrast, is a fully managed
implementation of an SMTP client.
So In MailAddress From = new MailAddress(FromName, FromName);
^
From = Gets or sets the e-mail address of the sender
Source

ASP.NET error sending mail

This is intranet application and I am using company's mail realy to send emails. It works fine in other applications I have but not in this one and everything is the same.
I get "System.Net.Mail.SmtpException: Syntax error in parameters or arguments. The server response was: 5.5.2 MAIL FROM syntax error" when attempting to send mail.
This is how I set it up:
MailMessage mm = new MailMessage();
mm.From = new MailAddress("NoReply#AMS_Redirection.company.org");
mm.To.Add(new MailAddress("my_emailaddress#company.org"));
mm.Subject = "AMS Redirection Error";
mm.Priority = MailPriority.Normal;
mm.IsBodyHtml = true;
mm.Body = "some html stuff here";
SmtpClient sc = new SmtpClient("mailrelay.company.org");
sc.Credentials = new NetworkCredential();
try
{
sc.Send(mm);
}
catch (SmtpException smtpEx)
{
//A problem occurred when sending the email message
string sScript = string.Format("alert(\"There was a problem in sending the email: {0}\");", smtpEx.Message.Replace("\r\n", " "));
ClientScript.RegisterStartupScript(this.GetType(), "SMTP Error", sScript, true);
}
I can successfully ping the mail relay.
Try setting the 'from' address to something you KNOW is wrong. I get this exception when the 'from' address is rejected by my SMTP forwarding service. If it still fails the same way you know the problem is in the config of the relay.
did you check if the smtp port of your SMTP server is the standard port? Otherwise you have to explicitly set it.

Resources