# How to configure Emacs to send email?



## neilms (Jul 10, 2012)

Hello,
I have read the relevant sections of the emacs manual hoping to get my emacs program set up to send email.

My ISP uses an SMTP server on port 465 and I have verified that the server is up and running by an nmap port scan. I have even inserted the IP number rather than the hostname address.

My machine is running FreeBSD 9 and is fully up to date.

This is the contents of my .emacs file:


```
(setq send-mail-function 'smtpmail-send-it
smtp-starttls-credentials '(("62.254.26.195" 465 nil nil))
smtpmail-auth-credentials (expand-file-name "~/.authinfo"))
(setq smtpmail-smtp-server "62.254.26.195")
(setq smtpmail-smtp-service 465)
```

When *I* C-C C-C to send the message, I get an error in the mini buffer that says:

```
Process SMTP not running
```
I have tried to find the answer via google but no clear answer seems to be available. Is anyone able to help with this?


----------



## jrm@ (Jul 10, 2012)

This works for me.


```
(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
      smtpmail-auth-credentials '(("smtp.gmail.com" 587 "my_username" nil))
      smtpmail-default-smtp-server "smtp.gmail.com"
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 587
      smtpmail-local-domain "mydomain")
```


----------



## jrm@ (Jul 11, 2012)

Is this one of the emacs from the FreeBSD ports?  Which one?  Does anything else show up in *Messages* or *Warnings*?

I see there is a bug report that matches what you describe, but it's specific to Windows.

http://lists.gnu.org/archive/html/bug-gnu-emacs/2011-01/msg00130.html

Have you tried adding

```
smtpmail-debug-info
smtpmail-debug-verb
```

to your ~/.emacs?

Can you connect without tls on port 25?


----------



## neilms (Jul 12, 2012)

I used identical syntax in my .emacs file and got prompted for a password. When I input the password I got a 'smtp protocol error' with my gmail account. My ISP smtp does not run on port 25 only port 465.


----------



## oops (Jul 12, 2012)

If you're connecting directly to SSL-port bypassing STARTTLS try setting

```
(setq smtpmail-stream-type 'tls)
```


----------



## purgatori (Jul 15, 2012)

This worked fine for me for a long time:


```
(setq smtpmail-smtp-server "smtp.hostname.net.au") 
   (setq smtpmail-smtp-service 25)
(setq smtpmail-debug-info t)
   (setq smtpmail-debug-verb t)
   (setq send-mail-function 'smtpmail-send-it)
   (setq message-send-mail-function 'smtpmail-send-it)
   (require 'smtpmail)
```

... but then my ISP changed *something* on their end, and I kept getting the same error you did (although you should have a look at the gnus backtrace (turn debug on, if you haven't already, using the relevant code from above)). Adding the following fixed the problem:


```
'(smtpmail-stream-type (quote plain))
```

You can also get there through: M-x customize-option <RET> smtpmail-stream-type <RET>

I don't know if any of that will be of help to you, but if not then I highly recommend posting your problem to the gnu.emacs.help mailing list. That's what I did, and I ended up receiving help from the guy who actually developed Gnus (i.e. Lars Ingebrigtsen).


----------

