Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

email - XAMPP Sendmail using Gmail account

I'm trying to configure Sendmail through XAMPP to send email. In my sendmail.ini I have these settings:

# Set default values for all following accounts.

logfile "C:xamppsendmailsendmail.log
account Gmail
tls on
port 587
tls_certcheck off
host smtp.gmail.com
from myemail@gmail.com
auth on
user myemail06@gmail.com
password mypassword

account default : Gmail

I've created a test script like this:

$to = "testemail@btinternet.com";
$subject = "Hi!";
$body = "Hi,

How are you?";
$headers = "From: myemail06@gmail.com" . "
";
if (mail($to, $subject, $body, $headers)) {
    echo ("Message successfully sent!");
} else {
    echo ("Message delivery failed...");
}

I get a message to say that the email was sent but it never arrives and in the logs I get:

sendmail: Error during delivery: Must issue a STARTTLS command first.

Does anybody know what the issue could be here?

Thanks in advance!

Gaz

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is what worked for me Hopefully no one else will burn oil to figure this out like i did.

Here is my sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=myemail@gmail.com
auth_password=yourgmailpassword
force_sender=myemail@gmail.com

php/php.ini ----basically comment everything out except sendmail_path & mail.add_x_header

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:xamppapachelogsphp_mail.log"

This worked for me after i updated the sendmail files (the old ones dont support smtp)

  • go to http://glob.com.au/sendmail/ and grab the latest sendmail zip file
  • unzip to desktop and copy the files into your xamppsendmail folder replacing everything that was there.EVERYTHING!
  • Now open up sendmail.ini and copy paste what i showed above.(remove everything in that file first or just comment everything out!)
  • NOTE: you dont need Mercury servers started for this.

I was making a password recovery php on localhost when i encountered this problem. I needed to send users their password. - your php looks okey


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...