Sending emails from localhost ASP.net - email

I am trying to send a confirmation mail after a user has registered on my website. I am using Webmatrix and ASP.NET to implement this.
I followed the code on this website http://www.asp.net/web-pages/tutorials/email-and-search/11-adding-email-to-your-web-site
For creating the SMTP server i used the IIS manager in Windows 7.
But its not working.
I changed the settings to
WebMail.SmtpServer = "localhost";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "name";
WebMail.From = "---#gmail.com";
WebMail.Password = "pass";
What do i put as my username and password for this? I am trying to test this on localhost. I dont have a server account.
Please help

great tutorial how to do this is
Sending email in .NET through Gmail
i have used it myself.
for sure i can see one error:
WebMail.SmtpServer = "localhost"; <-- is the provider you are using to send email
localhost is the PC what are you using (unless you have your own smtp server)
the link will help as its only small change you need to do and you can after investigate

To send an e-mail you need an e-mail account. Your application will contact that server to send e-mails (if you're using GMail remember you need SSL so set it to true). That's why you can't use localhost as SMPT server: it's not an e-mail server!
Configuration can be done in the web.config file. See this article for more details about how to configure and use SmtpClient class.

Related

Connect Zimbra OS with outlook

I´m very new to Zimbra and setting up mail servers.
I have the requirement to create domains with email accounts, so I´ve set up a virtual machine with zimbra.
It has worked fine until I created a new domain incl. account, which I wanted to connect with outlook.
I did this before with the host domain and it was no problem to send and retrieve mails via outlook, but with an other domain it doesn´t work.
I can access the account on the web interface.
When I try to connect with outlook it seems like it can´t find the domain name?
To sum up:
zimbra host: mail.example.local
admin#mail.example.local works with outlook
-> new domain + account in zimbra test#test.local doesn´t work with outlook
when I access test.local via browser I can login with test account.
Can anyone help me or give me an advice?
I can't find any information in the outlook log files...
Greets
In outlook you mast set imap/pop server mail.example.local or set dns A record test.local = mail.example.local

AWS Elastic Beanstalk - MAIL (Sending and receiving emails )

Well I have just managed to migrate my web application from shared hosting service to AWS, Using Elastic beanstalk . However I m struggling with emails service.
Well My Application sends verification email upon registration (using SMTP) , and it looks that users are not receiving emails. ( I'm still using the SMTP account of the shared hosting )
Also while using the shared hosting service, I used to create mail accounts for other team member using our website domain name, for instance ( noreply#domain.com).
Well I tried to look for a good answer regarding my question, but none of the question answers fully my needs.
some people recommend SES to only send emails and WorkMAil to receive Emails.
Well in My case I don't want to use other services.since my website is really small, so I wish someone can answer clearly the following questions:
1- How to allow the elastic beanstalk application sending emails using smtp.
2- how to setup a webmail on the EC2 instance ( to receive and send emails ), or at least setting up the mail service on the ec2 instance , and sending emails using other clients like outlook for instance.
3- how to create SMTP accounts or different email accounts using the domain name of the website.
PS : Please answer with very clear and detailed answer so I would understand , and everyone who might have the same problem.
As I recently came across the same issue (php mail() didn't seem to work on Beanstalk) - I'll share some insights. Perhaps it's already been said in here, but then see it as working end solution.
Problem
You are using PHP on AWS Beanstalk EC2. Your application uses the PHP native function called mail();. It doesn't seem to work when you upload and deploy the app.
Solution
1. Use SMTP with PHPmailer. (I'll explain below why).
https://github.com/PHPMailer, download it If you like package
management, Composer etc, you can use that, but if you like me, just
want to have something small and clean you will only need the
following files:
class.phpmailer.php
class.smtp.php
PHPMailerAutoload.php
Put these files in your own folder structure, like vendor/phpmailer/%the three files here%.
Take the following code and note that the top is "linking" to your PHPMailerAutoload.php. Put it in a file called "mail.php" (or whatever you want):
<?php
require '../vendor/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.hostname.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'username'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->setFrom('hello#example.com', 'Name');
$mail->addAddress('to#example.com', 'To Name'); // Add a recipient // Name is optional
$mail->addReplyTo('hello#example.com', 'Name');
//$mail->addCC('cc#example.com');
//$mail->addBCC('bcc#example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
(Note that I commented out some things you may not need, but could be good. Check PHPmailer git hub website on https://github.com/PHPMailer/PHPMailer/wiki for more tweaks).
Now you just need to run "mail.php" and it will send an email. Of course you have to use a real SMTP-server (it's also possible to use Gmail, but check PHPmailer for that). Once you see it in action, you can tweak this to work throughout your php application. You have to build a new function to use instead of PHP mail(). Why? I'll go to that in the next paragraph
Background/description
There is an assumption said in many threads that PHP's native function called Sendmail, or mail() doesn't work on EC2 (or Beanstalk). Not true. It does work. It's just sitting there and doesn't know what to do. Run a phpinfo.php and look for Sendmail. But it points to localhost. So it works the same way as on your localhost, it sends mail to your localhost. Which is not setup, so you don't see the email anyway (unless you use shell to read it, which no one does).
And, as some has pointed out, you shouldn't setup your (the same at least) Beanstalk EC2 as a mail server, because of scaling and other reasons, but mainly because it's ugly.
There are other ways to solve the problem. Using Amazon SES is one often suggested solution. Fair enough, if you want to send thousands of mails and make sure it works. It also costs, but that's almost nothing with current pricing at $0.10 for 1000 mails. So no real argument. SES could also offer a SMTP server and can be used in the above example.
I hope this helps.
For email hosting on AWS you can either use WorkMail or configure a mail server on an EC2 instance. Those are your only options unless you look to third party mail hosting service. There are plenty of tutorials out there for either option, so I won't go into that here.
You do not want to run a mail server on an Elastic Beanstalk server instance. That would result in duplicate mail servers being created if your application scales up, mail server(s) being deleted every time you update your application, and generally all sorts of issues. You would want to create a separate EC2 instance that isn't controlled by Beanstalk if you want to host a mail server on EC2.
For sending email via SMTP from your Elastic Beanstalk servers you would either use whatever mail hosting service you have chosen and configured, or use an SMTP email delivery service such as Amazon SES, or a third party service like SendGrid.

Jenkins throws "Client does not have permissions to send as this sender"

There is lots of posts with users having same error, but none of them works for me...
I am trying to send email reports in Hudson/Jenkins...
Our mail server uses SSL/TLS, I configured Jenkins for TLS, then I am getting this error:
Client does not have permissions to send as this sender
When I try javamail using code, it sends the email properly. Also, Thunderbird works fine.
Any ideas? Do I need to contact mail server administrators?
Finally got it, thanks to Friso
Had to set my email address in System Admin e-mail address under Jenkins Location.
The email should be changed in three places as below as per version 2.19.4:
Extended E-mail Notification - If using SMTP plugin
Email Notification - SMTP Authentication
Jenkins location - System Admin e-mail address
I had the same issue, and I discovered that credentials were no more valid, so I asked to the IT department who told me that credentials were no more need on LAN.
Now it works!

Mail server redirect to another server

I have a site, which has a server with "Parallels Plesk Panel" installed. I want to send an email from that site a "Contact Us" message to info#domain.com email.
The problem is that this email was already created by one of the programmers using the google mail system (apparently you can create accounts there with a domain name different from gmail.com).
So now, the server rejects my message, telling me that it can't find an email with this name. It works fine when I send to any other domain, but when sending to the same one, it fails. I've created another email info2#domain.com and sent emails there and it works.
My question now is, how do I send emails to the existent info#domain.com which is already created in gmail without making the server block me. One of the options I saw at this panel is to redirect the request for that email to another mailing system (and to specify its IP). Maybe that would help if I would to put there gmails IP?
Thanks.
EDIT:
Using my contact us form I am sending an email to info#domain.com. I get an SMTP error 550, can't find the mail box. When sending to anything but #domain.com it works. When adding that email to my server, it is also fine.
Now, the previous programmer already created info#domain.com, but not with our plesk panel, but using gmail server. Apparently, using gmail you can create an email of the type info#domain.com and not just info#gmail.com. The obvious problem is then that I try to send to this email. It sees that the server is domain.com and tries to find it there (same domain as the site from which I send the message). It fails and gives me the 550 error.
I want the server to send the email with that message to info#domain.com which is actually on gmail.
if I understand correctly, your problem is that two servers think they host the maildomain: your plesk server and gmail.
solution: disable local mail delivery for that domain on the plesk server and make sure plesk can correctly resolve the mx records of that domain , runing dig mx +short domain.com on the plesk server should return a google owned hostname, not the local hostname.
I don't own a plesk server, so I can't tell how how exactly to disable the mail domain, but a quick google search returns: http://www.serveridol.com/2011/03/16/disabling-email-service-for-a-domain-in-plesk/
http://search.yahoo.com/search?p=email+form+service&ei=UTF-8&fr=chr-greentree_ff&type=827316
try a remote email form service. most hosting companies' mail servers are local. to do this, you would have to make your own .htaccess file which contains php.ini mail server settings. i THINK this is correct. you can install php yourself to see what those settings are.
this is something you will probably have to do through the web hosting control panel.
and by the way, XHTML is served up as HTML unless you configure the server to serve XHTML up as XHTML. so use HTML when possible unless you know how to do that. here's how.
http://jesusnjim.com/web-design/setup-test-server.html

Using authsmtp from a Grails server

This is quite a specific question, and I have had no luck on the grails nabble forum, so I thought I would post here. I am using the grails mail plug-in, but I think my question is a general one about using authsmtp as an email gateway from my server.
I am having trouble sending mail from my app using authsmtp. I have installed and configured the mail plugin and was originally using my ISP's SMTP server to send mails. However when I deployed to AWS EC2 this failed because my elastic IP was blocked by the SMTP host. So I bought myself an authsmtp account and set up my server email address as an accepted one at authsmtp.
I then changed my configuration in SecurityConfig.groovy to point to the authsmtp server that I had been designated...
mailHost = "mail.authsmtp.com"
mailUsername = "myusername"
mailPassword = "mypassword"
mailProtocol = "smtp"
mailFrom = "valid-authsmtp-address#mydomain.com"
mailPort = 2525
...and I'm just trying to get this to work locally before I deploy back up to AWS. Sending mail fails and in my log I have this exception:
2010-02-13 10:59:44,218 [http-8080-1] ERROR service.EmailerService - Failed to send emails: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 513 5.0.0 Your email system must authenticate before sending mail.
org.springframework.mail.MailSendException; nested exception details (1) are:
Failed message 1:
com.sun.mail.smtp.SMTPSendFailedException: 513 5.0.0 Your email system must authenticate before sending mail. at
com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
I'm a bit lost since the username and password I provide in the
configuration are definitely correct.
A terse and not very helpful conversation with authsmtp support suggests
that I need to MD5 and/or base64 encode my credentials before sending, so my
question is in three parts...
1) any idea what's going on with the failure and why that message is
appearing?
2) how would I encode the credentials to pass to authsmtp and how would I
configure that for the mail plugin
3) has anyone successfully connected and sent mail through authsmtp from the
mail plugin and specifically from AWS EC2?
When sending Email using the Acegi plugin, under the hood a Spring JavaMailSenderImpl is used. Looking at its docs:
Note that the underlying JavaMail Session has to be configured with the property "mail.smtp.auth" set to true, else the specified password will not be sent to the mail server by the JavaMail runtime. If you are not explicitly passing in a Session to use, simply specify this setting via setJavaMailProperties(java.util.Properties).
So append to your SecurityConfig.groovy the following:
javaMailProperties = [ "mail.smtp.auth": true]
I didn't find a solution to this using the Grails mail plugin, so I'm still interested in an answer, however I did find a workround. It may be useful in case anyone else follows me down this lonely path.