如何在 Windows Azure 上使用 PHP 发送电子邮件? [英] How can i send an Email using PHP at windows Azure?

查看:31
本文介绍了如何在 Windows Azure 上使用 PHP 发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 windows Azure 上使用 PHP 发送电子邮件?

How can i send an Email using PHP at windows Azure?

我正在使用简单的邮件功能:

i am using simple mail function:

$to .= 'email-Id';
$subject = " Test Subject";

$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'To: '.$to.'' . "
";
$headers .= 'From: '.$name. '<'.$email.'>' . "
";

echo $message='email text here';
@mail($to, $subject, $message, $headers);

推荐答案

要使用 PHP 发送电子邮件,您有几个选择:

To send emails using PHP you have a few options:

选项 1:使用 SMTP

您需要修改您的 php.ini 配置文件 (http://php.net/manual/en/ref.mail.php) 并将 SMTP 值设置为您可以使用的外部 SMTP 服务器.SMTP 服务器目前不是 Windows Azure 功能的一部分.

You'll need to modify your php.ini configuration file (http://php.net/manual/en/ref.mail.php) and set the SMTP value to an external SMTP server you can use. SMTP servers are not part of the Windows Azure features at the moment.

[mail function]
SMTP = mail.mycompany.com

选项 2:使用 sendmail

您需要修改您的 php.ini 配置文件 (http://php.net/manual/en/ref.mail.php) 并将 sendmail_path 值设置为 sendmail 可执行文件.

You'll need to modify your php.ini configuration file (http://php.net/manual/en/ref.mail.php) and set the sendmail_path value to the sendmail executable.

[mail function]
sendmail_path = "C:wampsendmailsendmail.exe -t"

由于 Windows 中不存在 sendmail,您需要使用 Windows 的假 sendmail:http://glob.com.au/sendmail/

Since sendmail doesn't exist in Windows, you'll need to use the fake sendmail for windows: http://glob.com.au/sendmail/

选项 3:使用邮件/smtp 服务

您可以使用 SendGrid 之类的服务来发送电子邮件(他们为 Azure 用户提供优惠:http://sendgrid.com/azure.html).他们会负责发送电子邮件,您只需要调用 REST api:

You could use a service like SendGrid to send your emails (they have an offer for Azure users: http://sendgrid.com/azure.html). They'll take care of sending out the email, you'll just need to call the REST api:

$sendgrid = new SendGrid('username', 'password');
$mail = new SendGridMail();
$mail->addTo('foo@bar.com')->
       setFrom('me@bar.com')->
       setSubject('Subject goes here')->
       setText('Hello World!')->
       setHtml('<strong>Hello World!</strong>');
$sendgrid->smtp->send($mail);

这篇关于如何在 Windows Azure 上使用 PHP 发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆