不工作的电子邮件在实时服务器上发送Laravel

时间:2014-10-02 07:37:02

标签: email laravel laravel-4

它正在我的localhost上工作。但在实时服务器上工作不正常。 它显示以下错误 无法通过主机smtp.gmail.com建立连接[连接超时#110] 怎么解决?

我的app / config / mail.php

<?php

return array(

    'driver' => 'smtp',
    'host' => 'smtp.gmail.com',
    'port' => 465,
    'from' => array('address' => 'myaddress', 'name' => 'Name'),
    'encryption' => 'ssl',
    'username' => 'myemail@gmail.com',
    'password' => 'mypassword',
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,

);

2 个答案:

答案 0 :(得分:0)

尝试此配置:

return array(

    'driver' => 'smtp',
    'host' => 'smtp.gmail.com',
    'port' => 587,
    'from' => array('address' => 'myaddress', 'name' => 'Name'),
    'encryption' => 'tls',
    'username' => 'myemail@gmail.com',
    'password' => 'mypassword',
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,

);

希望这对您的本地服务器和实时服务器都有效。

答案 1 :(得分:0)

它将在laravel 5.1中发挥作用 在.env文件中 改变以下

import matplotlib.pyplot as plt
import matplotlib as mpl
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import numpy as np

#create some lons/lats
lats = np.linspace(20,40,50)
lons = np.linspace(110,130,50)
lons,lats = np.meshgrid(lons,lats)

#some data
thedata = np.zeros_like(lats)
#some 'cloud' in the data
thedata[5:8,7:13] = 1

#theproj = ccrs.Mercator()
theproj = ccrs.LambertConformal() #choose another projection to obtain non-rectangular grid
ef, axar = plt.subplots(1,1, subplot_kw={'projection': theproj})#, 'axisbg': 'w'
ef.subplots_adjust(hspace=0.,wspace=0.,bottom=0.05,top=0.95,left=0.03,right=0.98)    
axar.coastlines()

mycmap = mpl.colors.ListedColormap(['white', 'black'])
bounds=[0,0.5,1]
norm = mpl.colors.BoundaryNorm(bounds, mycmap.N)

im = axar.pcolormesh(lons,lats,thedata,cmap=mycmap, transform=ccrs.PlateCarree())
im.set_norm(norm)

#make the extent larger to see a margin outside of the domain
axar.set_extent([lons[0,0]-1,lons[-1,-1]+1,lats[0,0]-1,lats[-1,-1]+1])


#for illustration: make the domain bounds visible
#but instead of the red domain bounds I would like to have the background (outside of the domain) in some color (lightgrey)
axar.plot(lons[:,0],lats[:,0],'r', transform=ccrs.PlateCarree())
axar.plot(lons[:,-1],lats[:,0],'r', transform=ccrs.PlateCarree())
axar.plot(lons[0,:],lats[0,:],'r', transform=ccrs.PlateCarree())
axar.plot(lons[0,:],lats[-1,:],'r', transform=ccrs.PlateCarree())

#some decoration to see where we are
gl = axar.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
                  linewidth=2, color='gray', alpha=0.5, linestyle='--')
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER    

plt.show()

更改config / mail.php

MAIL_DRIVER=mail
MAIL_HOST=www.yourhost.com
MAIL_PORT=587
MAIL_USERNAME=your email address
MAIL_PASSWORD=email password
MAIL_ENCRYPTION=null