我正在尝试使用在Apache中运行的PHP通过IMAP连接到Gmail.这是在Ubuntu 9.04系统上.我有一些PHP配置问题,这使得它无法正常工作.首先,这是我为PHP设置IMAP所做的工作:
sudo apt-get install libc-client2007b libc-client2007b-dev
sudo apt-get install php5-imap
sudo /etc/init.d/apache2 start
Run Code Online (Sandbox Code Playgroud)
当我运行phpinfo()时,我得到以下imap值:
IMAP c-Client Version: 2004
SSL Support: enabled
Kerberos Support: enabled
Run Code Online (Sandbox Code Playgroud)
这是我的示例代码:
<?php
$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$user = 'my gmail address';
$password = 'my gmail password';
$connection = imap_open($connect_to, $user, $password)
or die("Can't connect to '$connect_to': " . imap_last_error());
imap_close($connection);
?>
Run Code Online (Sandbox Code Playgroud)
当我执行此代码时,我得到以下输出:
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in /var/www/clint/gmail/gmail.php on line 10
Can't connect to '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX': TLS/SSL failure for imap.gmail.com: SSL context failed
Run Code Online (Sandbox Code Playgroud)
请注意,我可以从这台计算机telnet到imap.gmail.com:993.我还可以通过IMAP将Evolution(邮件阅读器)连接到Gmail并毫无问题地获取邮件.所以,我认为这不是防火墙问题.我很确定我在PHP中没有正确设置. …
我偶尔会收到来自Google(accounts-noreply@google.com)的电子邮件,类似于以下内容:
Subject: Suspicious sign in prevented
Someone recently tried to use an application to sign in to your Google
Account, ________@gmail.com. We prevented the sign-in attempt in case
this was a hijacker trying to access your account. Please review the
details of the sign-in attempt:
Monday, November 19, 2012 8:40:55 PM GMT
IP Address: 184.72.161.49 (amazonaws.com)
Location: Dixmoor, IL, USA
If you do not recognize this sign-in attempt, someone else might be trying
to access your account. You …Run Code Online (Sandbox Code Playgroud) 发送邮件时,我收到此错误
java.lang.RuntimeException:javax.mail.SendFailedException:发送失败; 嵌套异常是:class javax.mail.MessagingException:无法连接到SMTP主机:smtp.gmail.com,port:465,响应:-1
我的代码是:
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("email","password");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("email"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(this.to));
message.setSubject("Testing");
message.setText("Hey, this is the testing email.");
Transport.send(message);
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
提前致谢.
我正在尝试使用以下代码在Windows上运行sendmailR:
## Not run:
from <- "<tal.galili@gmail.com>" # sprintf("<sendmailR@\\%s>", Sys.info()[4])
to <- "<tal.galili@gmail.com>"
subject <- "Hello from R"
body <- list("It works!", mime_part(iris))
sendmail(from, to, subject, body,
control=list(smtpServer="ASPMX.L.GOOGLE.COM."))
Run Code Online (Sandbox Code Playgroud)
并得到以下错误:
Error in socketConnection(host = server, port = port, blocking = TRUE) :
cannot open the connection
In addition: Warning message:
In socketConnection(host = server, port = port, blocking = TRUE) :
smtp.gmail.com tal.galili@gmail.com:statisfun:25 cannot be opened
Run Code Online (Sandbox Code Playgroud)
这里的答案为Linux提供了解决方案,我将非常感谢Windows用户的建议.
谢谢.
我试图通过设置gmail smtp从Django发送电子邮件.但每次它返回0状态.我在stackoverflow中搜索了不同的相关答案,我以相同的方式设置smtp服务器但仍然没有发送任何电子邮件..下面是我的设置文件
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'my gmail account'
EMAIL_HOST_PASSWORD = 'my gmail account password'
DEFAULT_FROM_EMAIL = 'my gmail account'
DEFAULT_TO_EMAIL = 'to email'
Run Code Online (Sandbox Code Playgroud)
以下是我的代码
from django.conf import settings
from django.core.mail import send_mail
print "Sending Email"
mail_title = 'Test Email'
message = 'This is a test email.'
email = settings.DEFAULT_FROM_EMAIL
recipients = [settings.DEFAULT_TO_EMAIL]
print send_mail(mail_title, message, email, recipients, settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD)
print "Email Sent"
Run Code Online (Sandbox Code Playgroud)
但每次打印状态为0表示不发送电子邮件.关于环境我在Amazon EC2实例上运行此代码,其中ubuntu作为操作系统,Apache作为服务器.
我是否需要通过gmail smtp进行其他设置来发送电子邮件?非常感谢您的帮助,提前致谢
我正在尝试发送一封深度链接到我的iOS应用的电子邮件,使用myapp://格式从电子邮件中打开它.它可以在任何iOS邮件客户端(邮件,邮箱等)中工作(即点击它打开应用程序),但不能在Gmail应用程序(甚至是网络版)中使用,它会将其删除而只留下文本.除了创建一个从浏览器重定向到应用程序的Web链接之外,有没有人有解决方案/替代方案?
当我使用Gmail发送电子邮件时,设置中定义的电子邮件签名会自动添加到电子邮件的底部.但是,当我打开mailto链接发送邮件时,不会自动添加电子邮件签名.
这是代码:
<a href="mailto:john@smith.com?subject=Thanks for your time&body=Hi,%0A%0AIt%20was%20a%20real%20pleasure%20speaking%20with%20you.%20Thank%20you%20for%20your%20time%20and%20we'll%20be%20in%20touch%20soon." target="_blank">test</a>
Run Code Online (Sandbox Code Playgroud)
而且有一个的jsfiddle 这里.当我从mailto链接发送电子邮件签名时,我需要做什么?
我正在尝试学习如何使用 python 发送电子邮件。我读过的所有网络教程都解释了如何使用 Gmail 进行操作。
但是,从 2022 年 5 月 30 日起(尽管每个人都可以自由地使用自己的帐户做任何他想做的事情),Google 制定了一项新政策,规定:
为了确保您的帐户安全,从 2022 年 5 月 30 日开始,Google 将不再支持使用仅要求您提供用户名和密码的第三方应用或设备。登录您的 Google 帐户。
来源: https: //support.google.com/accounts/answer/6010255
所以我的问题是有没有其他方法可以使用 python 发送电子邮件(包括属于其他公司的电子邮件帐户)?
这是我发送电子邮件的功能:
def send_email_fct(filename, filepath, fromaddr, mdpfrom, toaddr):
"""" filename: file name to be sent with extension
filepath: file path of the file to be sent
fromaddr: sender email address
mdpfrom: password of sender email address
toaddr: receiver email address"""
msg = MIMEMultipart() # instance of MIMEMultipart
msg['From'] = fromaddr
msg['To'] …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Gmail php xoath php示例,但是它需要输入消费者密钥和消费者密钥,我无法找到如何在Gmail api文档中获取.有没有人知道如何获取或知道任何相关文件?
当我尝试通过运行Laravel 4的网站发送电子邮件时,我遇到了以下异常:
{"error":{"type":"Swift_TransportException","message":"Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8 http:\/\/support.google.com\/mail\/bin\/answer.py?answer=14257 y70sm14744455qgd.3 - gsmtp\r\n\"","file":"\/var\/www\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php","line":386}}
Run Code Online (Sandbox Code Playgroud)
这是我的邮件配置:
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'mymail@gmail.com', 'name' => 'myname'),
'encryption' => 'ssl',
'username' => 'mymail@gmail.com',
'password' => 'lol',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
Run Code Online (Sandbox Code Playgroud)
我试过通过谷歌搜索这个问题找到的禁用链接,除了它没有什么区别.
有没有办法告诉谷歌"停止阻止这个IP,这是我"?